Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago

Getting date difference based on selected date

Hi,

 

I have a dataset that contains Order Date,Region,Account Number.

Order Date has Data from 1/1/2014 to 31/12/2018.

user want to pass a date value may be through slicer/parameter possibly. ex: 15/07/2015.
Date slicer/parameter should have list of values from 1/1/2014 to 31/12/2018.
based on the date selected by user(Slicer/parameter) which is 15/07/2015, I want to see the date difference b/w Selected Date (15/07/2015) and Order Date (1/1/2014 to 31/12/2018).

No of days = Datediff(order date,selected date,day).

 see the below picture for example,

 

Can anyone help me on this. A quick help would be much appreciated.

5 Replies

  • v-lili6-msft's avatar
    v-lili6-msft
    Community Support

    hi, Anonymous 

    You could get it as below:

    Step1:

    Create another date table for Date slicer/parameter.

    eg.  new table

    Date = CALENDARAUTO()
    Step2:
    selected date= SELECTEDVALUE( Date[Date] )
    Step3:
    No of days =
    DATEDIFF ( CALCULATE ( MAX ( Table[Order Date] ) ), [Selected Date], DAY )
     
    Then just drag Order date filed and these two measure into a table visual
     
    Best Regards,
    Lin
    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi,

       

      Thanks for the calculation.

      I have got the No of days days b/w selected date & order date.

      but the No of days is the measure where I won't be able to get Average of number of days.

      because once I get the No of days I need to calculate average of number of days which is not happening.

      we can get average of No of days if No of days is column instead of measure. but I try to create No of days as column it's giving me blank data.

       

      Is there anyway that we can get Average of No of Days per Region(or any dimension).

      Note: It's an important requiremnet for me to get Average of Numbe of days, almost 15 dashbaord using the same metric.

       

      A quick help would be much appreciated.

       

      Regards

      Harsha