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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
mohsin-raza
Helper III
Helper III

Time difference

mohsinraza_0-1640769897938.png

Hello:

 

I want to get time difference in above dataset .Can some body help to solve this problem?

 

regards.

 

1 ACCEPTED SOLUTION

@ryan_mayu  Thanks for reply. I like to get Time difference as i mentioned in my problem discription before. I solved it the concept of indexing like this way.

 

mohsinraza_0-1640850507485.png

Mean . How much  time the car takes traveling from Point1 to Pont2 and i got minutes now . There is some ambiguity in the result for exemple when car num change from 91 to 32,time difference is huge and it will solveble also and the expression i used is : 

 

TIME = 'Table'[Date]-IF('Table'[Index]=0,'Table'[Date],LOOKUPVALUE('Table'[Date],'Table'[Index],'Table'[Index]-1))

 

The problem is solved now.

@amitchandak  Thanks for your kind intiation in solving my problem.

View solution in original post

8 REPLIES 8
v-henryk-mstf
Community Support
Community Support

Hi @mohsin-raza ,

 

Thank you very much for your feedback! If the problem has been solved you can mark the reply for the standard answer to help the other members find it more quickly. If not, please point it out.


Looking forward to your feedback.


Best Regards,
Henry

amitchandak
Super User
Super User

@mohsin-raza , create new columns like

 

datetime = [Dtum_aktiv-Copy.1] +[Dtum_aktiv-Copy.2]

 

diff =
[datetime] = maxx(filter(Table,[datetime] <[datetime]),[datetime])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

I@amitchandak  thanks for reply . it is displaying empty column.

@mohsin-raza ,Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

serienummerDatumDistans
912021-06-01 05:280,000
912021-06-01 06:1337,465
912021-06-01 06:3211,545
912021-06-01 07:0527,904
912021-06-01 07:5640,581
912021-06-01 08:135,340
912021-06-01 08:319,787
912021-06-01 08:474,455
912021-06-01 09:4030,358
322021-06-01 04:380,000
322021-06-01 06:0168,783
322021-06-01 06:091,278
322021-06-01 06:2611,753
322021-06-01 06:4711,197
322021-06-01 07:021,874
322021-06-01 07:183,559
322021-06-01 07:376,595
322021-06-01 07:451,396
322021-06-01 07:543,201

This is  the dataset, where 91 and 32 are two cars .Process is  that (Car 91) start  at 2021-06-01 05:28 from (Point 1)and reach at (Point 2 )at 2021-06-01 06:13 and covering distan 37 km  and then from (Point 2)  to (Point 3) it reach at 2021-06-01 06:32 cover distance 11 km . I want to calculate difference in  Time(Time difference with  respect to Points and more ) here. Hope you understand the problem. 

912021-06-01 05:28                             0,000

First row goes like above.

They comebine both datum and distance

@mohsin-raza 

is this what you want?

Column = 
VAR _last=maxx(FILTER('Table','Table'[serienummer]=EARLIER('Table'[serienummer])&&'Table'[Datum]<EARLIER('Table'[Datum])),'Table'[Datum])
return DATEDIFF(_last,'Table'[Datum],SECOND)

1.PNG





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




@ryan_mayu  Thanks for reply. I like to get Time difference as i mentioned in my problem discription before. I solved it the concept of indexing like this way.

 

mohsinraza_0-1640850507485.png

Mean . How much  time the car takes traveling from Point1 to Pont2 and i got minutes now . There is some ambiguity in the result for exemple when car num change from 91 to 32,time difference is huge and it will solveble also and the expression i used is : 

 

TIME = 'Table'[Date]-IF('Table'[Index]=0,'Table'[Date],LOOKUPVALUE('Table'[Date],'Table'[Index],'Table'[Index]-1))

 

The problem is solved now.

@amitchandak  Thanks for your kind intiation in solving my problem.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.