Achieving Calculation Before Aggregation and Calculation After Aggregation in SAP HANA Modelling using Projection and Aggregation Views


While doing Calculation that involves Aggregation in SAP HANA Modelling, we would have come across scenarios where we would need to achieve Results based on Calculation before Aggregation and Calculation after Aggregation. In this blog post, I would be briefly explaining how to achieve this in SAP HANA Graphical Calculation View Modelling.

Main Problem:

As per the requirement of one of my customers, while developing a Production Planning Report, I wanted to calculate Expected Production based on a formula, which is the product of two fields namely machine speed and actual available time.

In order to achieve this, I have created a Calculated column in Projection View and applied the formula as shown in the below screenshot:

When Date field is used, Expected Production is calculated as per the formula against each Date field.

When Date field is removed, Expected_Production should be 537.84 (=7.47*72)(Since Expected_Production should be calculated after aggregating Actual_Available_Time (2.5+2.48+2.49=7.47) and Machine_Speed (24+24+24 = 72)). But we have got the result as 179.28. This is due to Calculation before Aggregation.


So, in order to perform Calculation After Aggregation, I have created a calculated column in aggregation before semantics.

With date field BUDAT included, both the calculated columns namely Expected_Production_Aggregation_SUM and Expected_Production_Projection_SUM fetch the same values.

On removal of Date field BUDAT (in my case), you can now notice that the Calculated column in aggregation node performs Aggregation after Calculation.

Thus, we have achieved the expected result in Expected_Production_Aggregation_SUM.


So, from this blog post you could have got an idea on how to achieve Calculation before Aggregation and Calculation after Aggregation in SAP HANA Modeling. Kindly feel free to post your comments and reviews about this blog.


Original Article:

Related blogs


Please enter your comment!
Please enter your name here