1. Overview
1.1 Expected effect
It is hoped to realize the display of the "circular period" value. For example, the value of the period in June 2008 will be displayed in the previous month: the order amount in May 2008, as shown in the figure below:
1.2 Implementation ideas
2. Concept
Grammar | previous_period(x_agg(array)) | Calculate the circular period value based on the date field added in the horizontal and vertical axis or row and column dimensions. |
---|---|---|
Parameter | x_agg(array) | The parameter is the indicator used for calculation, and the indicator must be an aggregate function or aggregate indicator. When the field dragged on the horizontal and vertical axis does not meet the calculation requirements of the function, the indicator will be marked in red. |
3. Example
previous_period(sum_agg(AMOUNT)): the "SIGNDATE" dragged by the user on the horizontal and vertical axis ("Year Month Day" grouping), then the calculation result of this indicator is that the "AMOUNT" is grouped and summarized according to the "Year Month Day", and then the data for the last day's amount is calculated.
Sample data: "Sales DEMO>FRDemo_ORDERS".
3.1 Calculate the monthly circular period amount
To calculate the "monthly circular period" amount, you need to change the grouping of the date indicator "SIGNDATE" to "Year Month", as shown in the following figure:
Add a new calculation indicator named "circular period", enter the formula: PREVIOUS_PERIOD(SUM_AGG(AMOUNT)), as shown in the figure below:
For the writing of functions, please refer to: Function Calculation Format.
3.2 Effect view