Forum Discussion

PaisleyPrince's avatar
PaisleyPrince
Advocate II
1 year ago
Solved

Using a Date Parameter in DAX

Hi, I would like to create a scenario where a user chooses a date which is then used to calculate the number of days,weeks and months between the user's chosen date and dates in a table column which...
  • Sahir_Maharaj's avatar
    1 year ago

    Hello PaisleyPrince,

     

    Can you please try creating a date parameter and use it to dynamically calculate the difference:

    Days Difference = 
    VAR ChosenDate = SELECTEDVALUE('Selected Date'[Date], TODAY())
    RETURN
        DATEDIFF(ChosenDate, MIN('YourTable'[DateColumn]), DAY)
    
    Weeks Difference = 
    VAR ChosenDate = SELECTEDVALUE('Selected Date'[Date], TODAY())
    RETURN
        DATEDIFF(ChosenDate, MIN('YourTable'[DateColumn]), WEEK)
    
    Months Difference = 
    VAR ChosenDate = SELECTEDVALUE('Selected Date'[Date], TODAY())
    RETURN
        DATEDIFF(ChosenDate, MIN('YourTable'[DateColumn]), MONTH)
    

    Hope this helps.