You want to create an item that outputs the total value for each aggregate key in the custom CDS View output item. However, even if "Sum" is set for Aggregation, the total value cannot be output as expected.
SAP S/4HANA Cloud
Unfortunately, aggregations cannot be achieved through the Custom CDS views app, this is a limitation. Aggregations are used to define the interpretation of numeric data e.g. in an analytical scenario. As a result to setting an aggregation, a field is e.g. interpreted as measure when you use it in a custom analytical query later on. That's why you must define an aggregation behavior for each numeric field in an analytical scenario, except for the representative key. Optionally, you can also define timestamps and dates as measures if this is required for your business case.
The aggregations are only covered in the analytical scenario together with Custom Analytical Queries app. There are no plans to include this functionality in the Custom CDS Views app. But it should be possible to achieve it with Embedded Steampunk.
For more conceptual details, about analytical scenarios, refer to Analytical Scenarios: Dimensions and Cubes.
You can also check 3201919 - Custom CDS Views – Frequently Asked Questions
sum, aggregation, custom cds views, analytical scenarios, output , KBA , BC-SRV-APS-GKE , Generic CDS Key User Editor , Problem