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
Anonymous
Not applicable

Best Method to calculate the difference between two date/times columns across multiple tables

Been trying to accurately calculate the date difference between two difference dates and times from two different columns.

 

I have a table of Job Ids, which has the created on date column for that table. 

 

I have another table jobresponse which has the succeedon column job response time. 

 

These two tables are related by 1 (Job Id) to many relationship. (Job response), and therefore to relate both tables I would have to use related table clause in my calculation.  I have tried the following calculation.

 

Time taken = datediff(JobID[createdon],sumx(RELATEDTABLE(slakpiinstances),slakpiinstances[responsetime]),hours) and  I get this as the following column.
 

 

 

powerbi date diff.PNG

 I want the time taken column to give me the values back in decimals simliar to this in hours rather than the zeros as decimal points

 

duration.PNG

also the provide me the right calculation by a row by row basis so if the response time is blank in one row for the same work order then the time taken would be blank on the time taken column.

 

All responses are appreciated.

1 ACCEPTED SOLUTION
v-gizhi-msft
Community Support
Community Support

hi,

 

According to your description, please try this measure:

Time taken = DIVIDE(DATEDIFF(Job[createdon],SUMX(RELATEDTABLE(slakpiinstances),slakpiinstances[Responsetime]),SECOND),60)

You can also use ‘Fixed’ to set how many decimals you want.

Here is my test table:

30.png31.png32.png

And remember to click ‘Show data with no item’ to shows the blank rows.

The result shows:

33.png

Here is my test pbix file.

pbix 

If you still have questions about it, please for free to let me know.

 

Best Regards,

Giotto Zhi

View solution in original post

2 REPLIES 2
v-gizhi-msft
Community Support
Community Support

hi,

 

According to your description, please try this measure:

Time taken = DIVIDE(DATEDIFF(Job[createdon],SUMX(RELATEDTABLE(slakpiinstances),slakpiinstances[Responsetime]),SECOND),60)

You can also use ‘Fixed’ to set how many decimals you want.

Here is my test table:

30.png31.png32.png

And remember to click ‘Show data with no item’ to shows the blank rows.

The result shows:

33.png

Here is my test pbix file.

pbix 

If you still have questions about it, please for free to let me know.

 

Best Regards,

Giotto Zhi

Anonymous
Not applicable

Thank you

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.