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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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])

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.

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
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.