Forum Discussion

zombieug's avatar
zombieug
Icon for Helper I rankHelper I
8 years ago

Datediff in Hours for a Datecolumn

Hi forum,

I have a datecolumn with delivery dates that i want to controll via a date slicer and demands aligned with each delivery date .

Lets say:

date slicer is set to delivery dates between: 20.01.2018 and 30.01.2018

 

results are:

20.01.2018 l 50 pcs

22.01.2018 l 20 pcs

25.01 2018 l 70 pcs

 

I need to create a measure that shows me date differences between all delivery dates in hours

20.01.2018 - 22.01.2018 = 2 days = 48 hours

20.01.2018 - 25.01.2018 = 5 days = 120 hours

22.01.2018 - 25.01.2018 = 3days = 72 hours

 

the idea is a resulting table that looks like this:

 

48 hours l 70 pcs --> delivery dates of 20.01 and 22.01 = 50 + 20

120 hours l 140 pcs --> delivery dates of 20.01 and 22.01 and 25.01 = 50 + 20 + 70

72 hours  l 90 pcs--> delivery dates of 22.01 and 25.01 = 20 +70

 

is this possible, and if so how?

 

 

 

 

1 Reply

  • Earliest Date = FIRSTDATE(date[date])
    Latest Date = LASTDATE(date[date])
    Days = DATEDIFF([Earliest Date],[Latest Date],DAY)
    Hours = DATEDIFF([Earliest Date],[Latest Date],HOUR)
    
    You can then drag these into a TABLE or MATRIX Visual to display your result and If you don't want to show columns but rather a text narrative build a text measure 
    
    Message = [Earliest Date]&" - "&[Latest Date]&" = "&[Days]&" days = "&[Hours]&" hours"