Forum Discussion

gauravnarchal's avatar
gauravnarchal
Post Prodigy
6 years ago
Solved

Date Difference

I need help with the measure to calculate the date difference between two dates in a table.   Once I have the days calculated, I then need to get the results as how many items were shipped between ...
  • Anonymous's avatar
    Anonymous
    6 years ago

    Hi gauravnarchal ,

     

    Check the following measures.

    Measure = 
    var datediff = DATEDIFF(SELECTEDVALUE('Table'[booking date]),SELECTEDVALUE('Table'[shipped date]),DAY)
    return
    SWITCH(TRUE(),datediff>=1&&datediff<=7,"1-7",datediff>=8&&datediff<=10,"8-10",datediff>=11&&datediff<=13,"11-13",datediff>=13,"13&more")
    
    Measure 2 = CALCULATE(DISTINCTCOUNT('Table'[id]),FILTER('Table',[Measure]=SELECTEDVALUE(days[days])))

    Result would be shown as below.

     

    Best Regards,

    Jay