Forum Discussion

Dodo96's avatar
Dodo96
Regular Visitor
1 year ago
Solved

Dynamic date difference

Hello,   I'm encountering some difficulties in calculating a dynamic date difference between a date in Table1 and the maximum date selected from a slicer. The slicer uses the Calendar table, which ...
  • pankajnamekar25's avatar
    1 year ago

    Hello Dodo96 

    DAX for calculated column

     

    Date Range Category =

    VAR SelectedMaxDate =

        CALCULATE (

            MAX ( 'Calendar'[Date] ),

            ALLSELECTED ( 'Calendar' )

        )

    VAR DaysDiff =

        DATEDIFF ( Table1[Date], SelectedMaxDate, DAY )

    RETURN

        SWITCH (

            TRUE(),

            DaysDiff <= 30, "Within 30 days",

            DaysDiff <= 60, "31 to 60 days",

            DaysDiff > 60, "Over 60 days",

            BLANK()

        )

    Thanks,
     Pankaj Namekar | LinkedIn

    If this solution helps, please accept it and give a kudos (Like), it would be greatly appreciated.