Forum Discussion

FletchNZ's avatar
FletchNZ
Frequent Visitor
8 years ago
Solved

DAX Help - Prior year rolling total

Hey all, I'm stuck trying to get a prior year 12 month rolling total dax Query working.   So first I have a 12 month rolling total which works great 12M Total Service Request:= CALCULATE ( ...
  • Anonymous's avatar
    Anonymous
    8 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