Forum Discussion
DAX Help - Prior year rolling total
- Anonymous8 years ago
HI FletchNZ,
I think it may related to filter conflict between different time intelligence functions.
Time Intelligence in Power BI Desktop
Optimizing DAX expressions involving multiple measures
If this is a case, I'd like to suggest you manually point out date range which dax formula calculate instead to nested multiple measures with specific filters.
Sample:
12M Total Service Request := VAR currDate = MAX ( 'Date'[Date] ) RETURN CALCULATE ( [Total Service Request], FILTER ( ALLSELECTED ( 'Date' ), [Date] >= DATE ( YEAR ( currDate )-1, MONTH ( currDate ), DAY ( currDate ) ) && [Date] <= currDate ) ) Prev 12M Total Service Request := VAR currDate = MAX ( 'Date'[Date] ) RETURN CALCULATE ( [Total Service Request], FILTER ( ALLSELECTED ( 'Date' ), [Date] >= DATE ( YEAR ( currDate ) - 2, MONTH ( currDate ), DAY ( currDate ) ) && [Date] <= DATE ( YEAR ( currDate ) - 1, MONTH ( currDate ), DAY ( currDate ) ) ) )Regards,
Xiaoxin Sheng
HI FletchNZ,
I think it may related to filter conflict between different time intelligence functions.
Time Intelligence in Power BI Desktop
Optimizing DAX expressions involving multiple measures
If this is a case, I'd like to suggest you manually point out date range which dax formula calculate instead to nested multiple measures with specific filters.
Sample:
12M Total Service Request :=
VAR currDate =
MAX ( 'Date'[Date] )
RETURN
CALCULATE (
[Total Service Request],
FILTER (
ALLSELECTED ( 'Date' ),
[Date]
>= DATE ( YEAR ( currDate )-1, MONTH ( currDate ), DAY ( currDate ) )
&& [Date] <= currDate
)
)
Prev 12M Total Service Request :=
VAR currDate =
MAX ( 'Date'[Date] )
RETURN
CALCULATE (
[Total Service Request],
FILTER (
ALLSELECTED ( 'Date' ),
[Date]
>= DATE ( YEAR ( currDate ) - 2, MONTH ( currDate ), DAY ( currDate ) )
&& [Date]
<= DATE ( YEAR ( currDate ) - 1, MONTH ( currDate ), DAY ( currDate ) )
)
)
Regards,
Xiaoxin Sheng
Thanks for that it worked a charm!
I end up having to move from a Dax generated date table to a M date generated table and that along with your formulas it all worked perfect. No idea why I was getting weird results from the www.SQLbi.com Dax date code.