Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
zombieug
Helper I
Helper I

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 1
Seward12533
Solution Sage
Solution Sage

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"

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.