1

I'm trying to calculate the average of a currency field in abap cds per faktura.

Since @DefaultAggregation: #AVG is not working, I've figured out another way to do this using this guide: Calculate Average in Analytics Engine

This is a quite simple workaround:

//Main field which is to be averaged is been default aggregated as sum
  @DefaultAggregation: #SUM
  NetDaysGranted,

//Count field sum as aggregation
 @DefaultAggregation: #SUM
 1              as Count,

by counting the "positions" and use @AnalyticsDetails.query.formula one layer above to div the amount by the amount of positions.

@AnalyticsDetails.query.axis: #COLUMNS
@EndUserText.label: 'Net Arrears Days'
@DefaultAggregation: #FORMULA
@AnalyticsDetails.query.formula :'NetDaysGranted / Count'
1            as  NetDaysGranted,

This works perfectly fine.

The only problem I have, is that in my case this is a currency field and I need to display the average in display currency.

the cds function currency_conversion however does not let me use the '1'. It throws following error:

Function CURRENCY_CONVERSION: For parameter AMOUNT only Columns,Paths,Parameters can be passed

Is there a possibility to use currency_conversion on a calculated field?

toffler
  • 1,231
  • 10
  • 27

0 Answers0