cancel
Showing results for 
Search instead for 
Did you mean: 

How create a subtotal in Custom CDS View

0 Kudos

Dear Sap Community,

I ask kindly if there is a way fro insert in the custom CDS View the possibility to create a subtotal grouped for Company and Customer (fr example)

Thanks a lot in advance
Natale

Accepted Solutions (1)

Accepted Solutions (1)

JZijderveld
Active Participant

Hi Natale,

Since CDS is a view on the db tables that's not the place to do subtotals. You should create a custom analytical query on top of the CDS which will have the subtotals and grouping functionality readily available.

Quite straightforward but help is here: https://help.sap.com/viewer/f544846954f24b9183eddadcc41bdc3b/1902.500/en-US/33f3a229ecfe438ca6b2053c...

good luck!

Jeroen

Answers (1)

Answers (1)

MartyMcCormick
Product and Topic Expert
Product and Topic Expert

Hi Natale

In addition to Jeroen's suggestion, when you create your custom CDS view you can use the SUM Aggregation on the Field Properties tab. Then if you select the field in your OData call, it will come back with the subtotal value.

For example, let's say you have CompanyCode, Customer and AmountInTransactionCurrency on a CDS view. On the Field Properties tab, if you select Sum in the Aggregation drop down and then if you call OData URL ?$select=AmountInTransactionCurrency,CompanyCode,Customer you will get a single record back with the entire transaction records aggregated. If you don't explicitly select AmountInTransactionCurrency, you would get all of the records back.

Thanks,

Marty