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
SOS4
Frequent Visitor

Date and Time diff from two tables

 
Hi,

I want to track how long it takes users to respond to work 'tickets'.
I have two dates from two related tables. Work details open date - work requests open date
But I can't figure out how to do the calculation and show the results in hours and minutes.


This is a sample of my data. I'd really appreciate any assistance!
Table 1: Work Details

LCLEnterDate
2022-05-04T21:41:04.9400000
2022-05-04T21:57:18.3830000
2022-05-05T13:36:06.1930000
2021-06-08T15:26:25.5530000

 

 

Table 2: WorkRequests

DateEntered
2021-08-25T07:21:38.5170000
2021-08-25T07:21:38.5170000
1 ACCEPTED SOLUTION
v-yangliu-msft
Community Support
Community Support

Hi  @SOS4 ,

Here are the steps you can follow:

1. Create calculated column.

Duration HH:MM:SS =
var _maxdate=MAXX(ALL('WorkRequests'),'WorkRequests'[DateEntered])
var _all=
SUMX(FILTER(ALL('Work Details'),'Work Details'[LCLEnterDate]=EARLIER('Work Details'[LCLEnterDate])),
'Work Details'[LCLEnterDate] - _maxdate) * 1
var _days=INT(_all)
var _time=_all-_days
return
FORMAT( _days, "#0D-" ) & FORMAT( _time, "hh:mm:ss")

2. Result:

vyangliumsft_0-1662528237602.png

 

If you need pbix, please click here.

Date and Time diff from two tables.pbix

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

View solution in original post

3 REPLIES 3
v-yangliu-msft
Community Support
Community Support

Hi  @SOS4 ,

Here are the steps you can follow:

1. Create calculated column.

Duration HH:MM:SS =
var _maxdate=MAXX(ALL('WorkRequests'),'WorkRequests'[DateEntered])
var _all=
SUMX(FILTER(ALL('Work Details'),'Work Details'[LCLEnterDate]=EARLIER('Work Details'[LCLEnterDate])),
'Work Details'[LCLEnterDate] - _maxdate) * 1
var _days=INT(_all)
var _time=_all-_days
return
FORMAT( _days, "#0D-" ) & FORMAT( _time, "hh:mm:ss")

2. Result:

vyangliumsft_0-1662528237602.png

 

If you need pbix, please click here.

Date and Time diff from two tables.pbix

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

amitchandak
Super User
Super User

@SOS4 , The tables need to have some common id table like work order id then you can have

 

sumx(Values(WorkOrder[Work Order ID]) , calculate(Datediff(Min(Table1[Date]), Max(Table2[Date]), Day) ) )

 

https://amitchandak.medium.com/power-bi-when-i-asked-you-to-create-common-tables-a-quick-dax-solutio...

Actually I was mistaken, The tables do not have unique values in common, though they are both connected to a third table.
Could this work?

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.

Top Solution Authors