Forum Discussion

nikhil893's avatar
nikhil893
New Member
9 years ago
Solved

How to dynamically calculate the difference between two dates selected from a slicer?

 

We want to calculate the difference in seconds  between the two dates( start and end) selected from a slicer. As we are very new to this could anyone please help us out?

 

Thank you,

Nikhil Pranav

  • Hi nikhil893,

     

    PorkChop's DAX expression works fine.

    Measure = DATEDIFF(MIN(Sales[Date]),MAX(Sales[Date]),DAY)&" Days"

     

    Regards,

    Charlie Liao

7 Replies

  • Hey dude.

     

    If you are doing this in dax it's super simple.

     

     

    =DATEDIFF([Startdate],[EndDate],second)
    • nikhil893's avatar
      nikhil893
      New Member

      PorkChop : We need to have the start and end dates to be selected from the user using a slicer. Will this measure work for that too ? We do not have any columns named ' Start date' and 'end date'. We have only one column as date which we are using in a slicer.

      • v-caliao-msft's avatar
        v-caliao-msft
        Microsoft Employee

        Hi nikhil893,

         

        PorkChop's DAX expression works fine.

        Measure = DATEDIFF(MIN(Sales[Date]),MAX(Sales[Date]),DAY)&" Days"

         

        Regards,

        Charlie Liao