Forum Discussion
Reddy5833
Helper II
3 years agoHow to calculate difference between current quarter and previous quarter
Hi, can somebody help me with this.
Available data
| Year-QTR | Quarter rank | usage |
| 2021-1 | 1 | 1021.4 |
| 2021-2 | 2 | 964 |
| 2021-3 | 3 | 1023.7 |
| 2021-4 | 4 | 1042.6 |
| 2022-1 | 5 | 1043 |
| 2022-2 | 6 | 1049 |
| 2022-3 | 7 | 1053 |
| 2022-4 | 8 | 1052 |
| 2023-1 | 9 | 1020 |
Expected result
The differnce for the first (Base) value must be blank.
Any help would be much appriciated. Thanks in advance.
Reddy5833 Try:
Measure = VAR __Current = SUM('Table'[usage]) VAR __CurrentQR = MAX('Table'[Quarter rank]) VAR __Previous = SUMX(FILTER(ALL('Table'),[Quarter rank] = __CurrentQR - 1),[usage]) VAR __Result = IF(__Previous = BLANK(),BLANK(),__Current - __Previous) RETURN __ResultGreg_Deckler Thanks a lot, it works perfect..
- Hi Greg_Deckler ,I got the answer to my question, I found it from your video ( MSHGQM - Power BI DAX - Don't Use CALCULATE!)Measure to be used when there are multiple categories.
Measure 1 =VAR __Site = VALUES('Sample'[Site Name])VAR __Current = sum('Sample'[Usage])VAR __Table = FILTER(ALLSELECTED('Sample'),'Sample'[Site Name] in __Site)VAR __CurrentQR = MAX('Sample'[YQRank])VAR __Previous = SUMX(FILTER(__Table,[YQRank] = __CurrentQR - 1), [Usage])VAR __Result = IF(__Current=BLANK(),"0",__Current - __Previous)RETURN__Result