Forum Discussion
Lili304
3 years agoNew Member
Need help with DAX previous quarter
Hi experts! Can you please take a look at my issue about calculating quarter over quarter changes below and advise how to fix it? I have a item table that contains a list of items and their v...
- Anonymous3 years ago
Hi Lili304 ,
Here I create a sample to show you how to achieve your goal.
My Sample:
Data Model:
Measure:
Previous = VAR _PREVIOUS_QUARTER = CALCULATE ( MAX ( DimPeriod[Period] ), FILTER ( ALLEXCEPT ( 'Table', 'Table'[Item] ), 'Table'[Period] < MAX ( DimPeriod[Period] ) ) ) VAR _RESULT = CALCULATE ( SUM ( 'Table'[Values] ), FILTER ( ALLEXCEPT ( 'Table', 'Table'[Item] ), 'Table'[Period] = _PREVIOUS_QUARTER ) ) VAR _MAXPERIOD = MAX ( 'Table'[Period] ) RETURN IF ( SELECTEDVALUE ( DimPeriod[Period] ) > _MAXPERIOD, BLANK (), _RESULT )Diff = SUM('Table'[Values]) - [Previous]Result is as below.
Best Regards,
Rico ZhouIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
3 years agoNot applicable
Hi Lili304 ,
Here I create a sample to show you how to achieve your goal.
My Sample:
Data Model:
Measure:
Previous =
VAR _PREVIOUS_QUARTER =
CALCULATE (
MAX ( DimPeriod[Period] ),
FILTER (
ALLEXCEPT ( 'Table', 'Table'[Item] ),
'Table'[Period] < MAX ( DimPeriod[Period] )
)
)
VAR _RESULT =
CALCULATE (
SUM ( 'Table'[Values] ),
FILTER (
ALLEXCEPT ( 'Table', 'Table'[Item] ),
'Table'[Period] = _PREVIOUS_QUARTER
)
)
VAR _MAXPERIOD =
MAX ( 'Table'[Period] )
RETURN
IF ( SELECTEDVALUE ( DimPeriod[Period] ) > _MAXPERIOD, BLANK (), _RESULT )Diff = SUM('Table'[Values]) - [Previous]
Result is as below.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- Lili3043 years agoNew Member
Thank you Rico!