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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
Anonymous
Not applicable

Need Help calculating hour difference with datediff function

Hi everyone,

 

I am using a calculated Column "Hours" to calculate the hour differences between created and resource confirmed. The formula I am using is: 

Hours to Assign = DATEDIFF((CRQ_TASKS[Received]), (CRQ_Tasks[ResourceConfirmed]), HOUR)

 

However the results aren't all accurate especially for higher values. See Task 3 for example, it shows 105 hours but if you look at the date created and date confirmed it shows that its on the same day. The hours should be negative, if anything, since date created is later than date confirmed (entry error by user). When I switch the formula to MINUTE, the same thing happens. Task 11 shows 2 hours but it is still a wrong calculation.

 

The hours variable shows the same values regardless of "dont summarize" or "average". 

 

Any ideas on how to calculate hours in terms of 0.## or in hours and minutes accurately? Also why is this error occurring?

 

Thanks!

 

The sample data is as follows:

 

Created                                  ResourceConfirmed    Task             Hours       

2/6/2019 10:06:41 AM2/11/2019 4:15:00 PM1144 
2/7/2019 9:33:04 AM2/11/2019 3:55:00 PM2121 
2/19/2019 9:13:21 AM2/19/2019 9:10:00 AM3105 
2/19/2019 9:10:32 AM2/19/2019 9:00:00 AM497 
2/8/2019 12:44:20 PM2/11/2019 4:40:00 PM579 
2/11/2019 2:43:05 PM2/11/2019 2:40:00 PM672 
2/11/2019 2:45:57 PM2/11/2019 3:50:00 PM772 
2/4/2019 8:29:36 AM2/4/2019 8:25:00 AM865 
2/5/2019 8:46:50 AM2/5/2019 8:45:00 AM932 
2/7/2019 9:07:12 AM2/7/2019 9:05:00 AM102 
2/11/2019 9:02:13 AM2/11/2019 9:10:00 AM112 
2/13/2019 11:48:22 AM2/13/2019 10:50:00 AM122 
2/11/2019 9:06:57 AM2/11/2019 9:05:00 AM132 
2/13/2019 2:25:05 PM2/13/2019 2:25:00 PM142 
2/13/2019 2:40:44 PM2/13/2019 2:40:00 PM152 
2/13/2019 4:29:00 PM2/13/2019 4:25:00 PM162 
2/13/2019 4:37:37 PM2/13/2019 4:35:00 PM172 
2/6/2019 2:44:39 PM2/6/2019 12:00:00 PM182 
2/5/2019 8:08:30 AM2/5/2019 8:00:00 AM191 
2/4/2019 10:43:58 AM2/4/2019 10:45:00 AM201 
2/5/2019 8:50:53 AM2/5/2019 8:30:00 AM211 
2/6/2019 3:10:20 PM2/6/2019 12:00:00 AM220 
3 REPLIES 3
Anonymous
Not applicable

Created                                ResourceConfirmed     Hours      Task

2/6/2019 10:06:41 AM2/11/2019 4:15:00 PM1441
2/7/2019 9:33:04 AM2/11/2019 3:55:00 PM1212
2/19/2019 9:13:21 AM2/19/2019 9:10:00 AM1053
2/19/2019 9:10:32 AM2/19/2019 9:00:00 AM974
2/8/2019 12:44:20 PM2/11/2019 4:40:00 PM795
2/11/2019 2:43:05 PM2/11/2019 2:40:00 PM726
2/11/2019 2:45:57 PM2/11/2019 3:50:00 PM727
2/4/2019 8:29:36 AM2/4/2019 8:25:00 AM658
2/5/2019 8:46:50 AM2/5/2019 8:45:00 AM329
2/8/2019 11:17:20 AM2/8/2019 11:15:00 AM2110

2/11/2019 9:02:13 AM 
2/11/2019 9:10:00 AM211

 

Hi everyone,

 

I am using a calculated Column "Hours" to calculate the hour differences between created and resource confirmed. The formula I am using is: 

Hours to Assign = DATEDIFF((CRQ_TASKS[Received]), (CRQ_Tasks[ResourceConfirmed]), HOUR)

 

However the results aren't all accurate especially for higher values. See Task 3 for example, it shows 105 hours but if you look at the date created and date confirmed it shows that its on the same day. The hours should be negative, if anything, since date created is later than date confirmed (entry error by user). When I switch the formula to MINUTE, the same thing happens. Task 11 shows 2 hours but it is still a wrong calculation.

 

The hours variable shows the same values regardless of "dont summarize" or "average". 

 

Any ideas on how to calculate hours in terms of 0.## or in hours and minutes accurately? Also why is this error occurring?

 

Thanks!

 

Anonymous
Not applicable

Hi @Anonymous ,

 

In fact, datediff function works on my side. Can you please provide a sample pbix for test?

11.png

 

Regards,

Xiaoxin Sheng

ElenaN
Resolver V
Resolver V

Hello,

 

I tried your formula with the sample data you provided and can't reproduce the same result. For hours i get 0 for Task3 and for minutes i get -3. 

 

Maybe you can give more details or share your pbix (hide sensitive data if it is the case) to test.

 

Regards,

ElenaN

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.