Forum Discussion
Power BI QoQ Calculation DAX
Hi there,
I'm calculating QoQ Imp and QoQ %Eng in the below data table which is grouped by with the help of power query by adding "Index starting from 0" and "Index.1 starting from 1".
Table A
| Qtr | Filter | Imp | Eng | % Eng | Index | Index.1 | QoQ Imp | QoQ %Eng |
| Q1 2021 | ABC | 1524 | 106 | 6.96% | 0 | 1 | ||
| Q2 2021 | ABC | 2014 | 187 | 9.29% | 1 | 2 | ||
| Q3 2021 | ABC | 2065 | 239 | 11.57% | 2 | 3 | ||
| Q4 2021 | ABC | 2287 | 345 | 15.09% | 3 | 4 | ||
| Q1 2021 | XYZ | 2543 | 432 | 16.99% | 4 | 5 | ||
| Q2 2021 | XYZ | 3422 | 643 | 18.79% | 5 | 6 | ||
| Q3 2021 | XYZ | 3598 | 764 | 21.23% | 6 | 7 | ||
| Q4 2021 | XYZ | 3673 | 854 | 23.25% | 7 | 8 | ||
| Q1 2021 | AUS | 1743 | 120 | 6.88% | 8 | 9 | ||
| Q2 2021 | AUS | 1976 | 211 | 10.68% | 9 | 10 | ||
| Q3 2021 | AUS | 2032 | 287 | 14.12% | 10 | 11 | ||
| Q4 2021 | AUS | 2355 | 399 | 16.94% | 11 | 12 | ||
| Q1 2021 | IND | 3211 | 432 | 13.45% | 12 | 13 | ||
| Q2 2021 | IND | 3643 | 521 | 14.30% | 13 | 14 | ||
| Q3 2021 | IND | 3798 | 607 | 15.98% | 14 | 15 | ||
| Q4 2021 | IND | 3898 | 721 | 18.50% | 15 | 16 |
I have a "filter" column in the Filters pane this visual.
Please help me in calculating QoQ Imp and QoQ %Eng in the above Table A. The expected result/output should look like this below table:-
| Qtr | Filter | Imp | QoQ Imp | Eng_Sum | % Eng | QoQ %Eng |
| Q1 2021 | IND | 3211 | - | 432 | 13.45% | - |
| Q2 2021 | IND | 3643 | 13% | 521 | 14.30% | 6.30% |
| Q3 2021 | IND | 3798 | 4% | 607 | 15.98% | 11.75% |
| Q4 2021 | IND | 3898 | 3% | 721 | 18.50% | 15.73% |
I'm new to Power BI, any help would be much appreciated.
Thanks in Advance,
AK
Hi, Anonymous
You can try calculated columns as below:
QoQ Imp = VAR lastImp = LOOKUPVALUE ( 'Table A'[Imp], 'Table A'[Filter], 'Table A'[Filter], 'Table A'[Index], 'Table A'[Index] - 1 ) RETURN IF ( ISBLANK ( lastImp ), BLANK (), ( 'Table A'[Imp] - lastImp ) / lastImp )QoQ %Eng = VAR last_Engpercent = LOOKUPVALUE ( 'Table A'[% Eng], 'Table A'[Filter], 'Table A'[Filter], 'Table A'[Index], 'Table A'[Index] - 1 ) RETURN IF ( ISBLANK ( last_Engpercent ), BLANK (), ( 'Table A'[% Eng] - last_Engpercent ) / last_Engpercent )Please check my sample file for more details.
Best Regards,
Community Support Team _ Eason
2 Replies
- lbendlin
Super User
You may want to add a Calendar table to your data model, and then add a stand-in date column to your fact table (for example first day of quarter).
That removes the need for your index columns and allows you to use the standard DAX time intelligence functions.
- v-easonf-msft
Community Support
Hi, Anonymous
You can try calculated columns as below:
QoQ Imp = VAR lastImp = LOOKUPVALUE ( 'Table A'[Imp], 'Table A'[Filter], 'Table A'[Filter], 'Table A'[Index], 'Table A'[Index] - 1 ) RETURN IF ( ISBLANK ( lastImp ), BLANK (), ( 'Table A'[Imp] - lastImp ) / lastImp )QoQ %Eng = VAR last_Engpercent = LOOKUPVALUE ( 'Table A'[% Eng], 'Table A'[Filter], 'Table A'[Filter], 'Table A'[Index], 'Table A'[Index] - 1 ) RETURN IF ( ISBLANK ( last_Engpercent ), BLANK (), ( 'Table A'[% Eng] - last_Engpercent ) / last_Engpercent )Please check my sample file for more details.
Best Regards,
Community Support Team _ Eason