cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

S4 HANA cloud,How to use the SUM function in CDS?

max128
Explorer
0 Kudos
1,540

S4 HANA cloud,How to use the SUM function in CDS?

The consultant added the calculation field to the CDS and used the SUM function and the group by function in the filter. As a result, we got the value of the total.
Does this comply with SAP specifications? Is there another way to help advisors calculate totals in CDS?

max128_0-1735617161712.png

max128_1-1735617221380.png

 

Accepted Solutions (0)

Answers (2)

Answers (2)

Tayane
Product and Topic Expert
Product and Topic Expert
0 Kudos

Dear Max,

 

If you only want to aggregate values, you can use the aggregation specification in "Element Properties" tab in the Custom CDS View.

You can refer to SAP Help Portal | Element Properties.

 

Kind regards.

max128
Explorer
0 Kudos
My requirement is to calculate the total outbound quantity, and then join it with other CDS data.Duplicate data will appear when connecting with other CDS using this aggregation specification.
Pooja_Hadagali1
Product and Topic Expert
Product and Topic Expert
0 Kudos

In order to add the Calculation in CDS view follow the below steps

  1. Open the Custom CDS Views App
  2. Go to "Elements" tab
  3. Click on "Add" and select "Calculation".
  4. Use the expression editor to define your calculation by adding fields from the underlying data sources, and using operands and expressions. For available functions, refer to Functions for Calculations.

For more information, please check: SAP Help Portal | Calculated Fields

If you want to sum two fields in a Custom CDS View, you cannot perform the aggregation directly. However, you can set a default aggregation, such as SUM, in the field properties

You can also refer the existing thread

How to do Calculations in CDS View While creating ... - SAP Community

max128
Explorer
0 Kudos
The "SUM" function is not mentioned in "Functions for Calculations", but as shown in the first screenshot, I used the "SUM" function, and in the second screenshot, I used "group by", thus I calculated a summary number.My requirement is to calculate the total outbound quantity, and then join it with other CDS data.I wonder if doing so meets the requirements of SAP and whether it will be prohibited in the future.