Forum Discussion

DineshArivu's avatar
DineshArivu
Icon for Helper I rankHelper I
1 year ago
Solved

Rolling 3 months not working properly

Hi Experts,   I want to create a dax to display the last 3 months when we select any month from the slicer. if not selected then it will display all month data in clustered column chart. Monthname...
  • johnt75's avatar
    johnt75
    1 year ago

    You would need separate date tables for the visual and for the slicer. You can use the method described in the article I posted, or you could just have a disconnected copy of your date table which you use on the slicer, using the current date table in the visuals, and change the code to 

    Last 3 months =
    VAR HasMonthSelected =
        ISFILTERED ( 'CustomCalendar for slicer'[MonthName] )
    VAR EndDate =
        MAX ( 'CustomCalendar for slicer'[Date] )
    VAR SelectedDate =
        MAX ( 'CustomCalendar'[Date] )
    VAR Result =
        SWITCH (
            TRUE (),
            HasMonthSelected
                && SelectedDate IN DATESINPERIOD ( 'CustomCalendar'[Date], EndDate, -3, MONTH ), 1,
            HasMonthSelected, 0,
            1
        )
    RETURN
        Result