How to do Window Aggregation calculation?
I would like to know how we can create Window Aggregate calculations such as SUM(Sales) Over(Partition by Invoice Number) can be done in Pyramid Analytics.
Fore reference, please see the grid in the attached image. In this grid, one Invoice may have multiple Line Items. I want to calculate the Invoice Level Total (the highlighted one). I want this to be calculated while all these fields are present in the grid.
5 replies
-
Hi
We don't have a context calculation as a simple SUM for which you can adjust the window over which it operates.
However, there is no need as this can be easily created using a simple Formulate calculation.
Generally when you create a Measure, it will be evaluated in the the context of your query. In your example for each Line Item in the Invoice. What we need to do is tell Pyramid to ignore the Invoice Status, Line Item No., Line Item Type and only Aggregate for Invoice Number and Date or alternatively consider all Invoice Status, Line Item No., Line Item Type values for each Invoice Number and Date.
Create a new Formulate and add the Data Point block to the canvas. Select your Measure, Sales, then for each of Invoice Status, Line Item no and Line Item Type, check the All checkbox. this will effectively tell Pyramid's query engine to aggregate all the members in that dimension, even if they are in the query as separate elements.
When this Measure is used in your grid, it will aggregate by Invoice Number and Date, but not for the other dimensions in the query:
Hope that helps!
Ian
-
For the record, there are "Window" functions for context calculations - which is a specific family of calculations that are dependent on how they are deployed in a give report. You can see them here.