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
nogi
Advocate II
Advocate II

DATEDIFF - Results to be in hours - can't quite get it right?

I want to show task slippage from a project schedule in hours. Closed tasks should be against the planned and actual date/time and all open tasks against the current date/time. Using the suggested answer from: http://community.powerbi.com/t5/Desktop/How-to-subtract-a-column-with-Date-and-time-from-current-tim... I derived:

 

Column: HourlyFinishVariance = IF(ISBLANK('Tasks'[TaskActualFinishDate].[Date]),
						if(Tasks[TaskFinishDate].[Date]>NOW(),
							-DATEDIFF(NOW(),Tasks[TaskFinishDate].[Date],HOUR),DATEDIFF(Tasks[TaskFinishDate].[Date],NOW(),HOUR)),
						IF(Tasks[TaskFinishDate].[Date]>Tasks[TaskActualFinishDate].[Date],
							-DATEDIFF(Tasks[TaskActualFinishDate].[Date],Tasks[TaskFinishDate].[Date],HOUR),DATEDIFF(Tasks[TaskFinishDate].[Date],Tasks[TaskActualFinishDate].[Date],HOUR)))
							

It seems to work ok for closed tasks but doesn't seem to be returning the correct answer for open tasks. It's only returning values like 23hrs or 47hrs (almost 24hr clock less an hour):

Capture.PNG

 

 

 

1 REPLY 1
v-huizhn-msft
Employee
Employee

Hi @nogi,

After check, the syntax of formula is right? Could you please share your sample date for further analysis? Do hide sensitive information when you upload it. Or you can create dummy sample table if your data is private.

Best Regards,
Angelia

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.