Forum Discussion
Help with DAX - YOY
- 11 months ago
Hi,
In the previous year measure, try not to use REMOVEFILTERS DAX function, because it will remove all filters even users select year from year-slicer on the report.
Instead, try to use ALLSELECTED() DAX function and please check if it works. And then, we can start from there to optimize the DAX.REMOVEFILTERS function (DAX) - DAX | Microsoft Learn
ALLSELECTED function (DAX) - DAX | Microsoft Learn
total prev yr = VAR _currentyear = YEAR ( CALCULATE ( MAX ( data[RejectDate] ), ALLSELECTED () ) ) VAR _previousyr = MAXX ( FILTER ( ALL ( 'Calendar' ), 'Calendar'[Year] = _currentyear ), 'Calendar'[Year] ) VAR _count2 = CALCULATE ( [Count_NotApprov], 'Calendar'[Year] = _previousyr - 1 ) RETURN IF ( [Current Yr NotAppr], _count2 )
Hi,
In the previous year measure, try not to use REMOVEFILTERS DAX function, because it will remove all filters even users select year from year-slicer on the report.
Instead, try to use ALLSELECTED() DAX function and please check if it works. And then, we can start from there to optimize the DAX.
REMOVEFILTERS function (DAX) - DAX | Microsoft Learn
ALLSELECTED function (DAX) - DAX | Microsoft Learn
total prev yr =
VAR _currentyear =
YEAR ( CALCULATE ( MAX ( data[RejectDate] ), ALLSELECTED () ) )
VAR _previousyr =
MAXX (
FILTER ( ALL ( 'Calendar' ), 'Calendar'[Year] = _currentyear ),
'Calendar'[Year]
)
VAR _count2 =
CALCULATE ( [Count_NotApprov], 'Calendar'[Year] = _previousyr - 1 )
RETURN
IF ( [Current Yr NotAppr], _count2 )