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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
rpinxt
Solution Sage
Solution Sage

Dax for calculated column to take start time of next row as end time current row

So to illustrate:

rpinxt_0-1720707407340.png

Is there a way to get with DAX column P (Log Time End).

I saw solution with making two index tables one start from 0 and one from 1.

Then merge and that way get the 2 timestamps on the same line.

 

Made me think.....should be simpler way...

 

So is there some dax code to get in the context of Day and User the log time of the next row as the log time end of the current row?

2 ACCEPTED SOLUTIONS
mickey64
Super User
Super User

Step 0: I use this simple DATA table below. (I add a 'Index' column in Power Query Editor.)

mickey64_0-1720712644632.png

 

Step 1: I add a column below.

    Log Time Start = LOOKUPVALUE(LogData[Log Time End],LogData[Index],[Index]-1)

mickey64_3-1720713147598.png

 

 

View solution in original post

rpinxt
Solution Sage
Solution Sage

Thanks @mickey64 , so you still would need 1 index table (makes things indeed easier).

You used -1 to get the start time. I used +1 to get the end time.

 

But there was still one thing to overcome :

rpinxt_0-1720774042108.png

You see here when a new user start the end time is not correct of course.

The line of 15:32:37 for user ALHAJJX is the last line of that day for the user so should be blank.

 

Therefore I made the logic like:

rpinxt_2-1720774284514.png

So only when current user (c_user) is equal to next user (n_user) lookup the end time.

Works nicely:

rpinxt_3-1720774361951.png

 

So thanks for putting me in the right direction 😄

 

 

 

 

View solution in original post

2 REPLIES 2
rpinxt
Solution Sage
Solution Sage

Thanks @mickey64 , so you still would need 1 index table (makes things indeed easier).

You used -1 to get the start time. I used +1 to get the end time.

 

But there was still one thing to overcome :

rpinxt_0-1720774042108.png

You see here when a new user start the end time is not correct of course.

The line of 15:32:37 for user ALHAJJX is the last line of that day for the user so should be blank.

 

Therefore I made the logic like:

rpinxt_2-1720774284514.png

So only when current user (c_user) is equal to next user (n_user) lookup the end time.

Works nicely:

rpinxt_3-1720774361951.png

 

So thanks for putting me in the right direction 😄

 

 

 

 

mickey64
Super User
Super User

Step 0: I use this simple DATA table below. (I add a 'Index' column in Power Query Editor.)

mickey64_0-1720712644632.png

 

Step 1: I add a column below.

    Log Time Start = LOOKUPVALUE(LogData[Log Time End],LogData[Index],[Index]-1)

mickey64_3-1720713147598.png

 

 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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.

Top Solution Authors
Top Kudoed Authors