March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hi all,
I'm looking for a way get the timestamp of the previous row onto the current row. So that when they're on the same row, I can calculate the time difference for each user.
Example:
UserID | Timestamp | Previous row's timestamp | Calculated time difference (mm:ss) |
001 | 14:50:00 | ||
001 | 14:52:30 | 14:50:00 | 02:30 |
001 | 14:55:30 | 14:52:30 | 03:00 |
001 | 14:58:10 | 14:55:30 | 02:40 |
002 | 08:58:10 | ||
002 | 09:00:00 | 08:58:10 | 01:50 |
002 | 09:01:00 | 09:00:00 | 01:00 |
002 | 09:01:20 | 09:01:00 | 00:20 |
So the first and second column is an existing column in the report.
The third column is what I need.
The fourth column I can manage once I have the third column in place.
How to create the second column using DAX, without using the Power Query Editor?
Any help would be appreciated, thanks!
Solved! Go to Solution.
Hi,
Please check the below picture and the attached pbix file.
OFFSET function (DAX) - DAX | Microsoft Learn
Previous CC =
SELECTCOLUMNS (
OFFSET (
-1,
Data,
ORDERBY ( Data[Timestamp], ASC ),
,
PARTITIONBY ( Data[UserID] ),
MATCHBY ( Data[UserID], Data[Timestamp] )
),
Data[Timestamp]
)
Diff CC =
IF ( NOT ISBLANK ( Data[Previous CC] ), Data[Timestamp] - Data[Previous CC] )
If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.
Works great, thanks a lot!
Hi,
Please check the below picture and the attached pbix file.
OFFSET function (DAX) - DAX | Microsoft Learn
Previous CC =
SELECTCOLUMNS (
OFFSET (
-1,
Data,
ORDERBY ( Data[Timestamp], ASC ),
,
PARTITIONBY ( Data[UserID] ),
MATCHBY ( Data[UserID], Data[Timestamp] )
),
Data[Timestamp]
)
Diff CC =
IF ( NOT ISBLANK ( Data[Previous CC] ), Data[Timestamp] - Data[Previous CC] )
If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
124 | |
89 | |
84 | |
70 | |
51 |
User | Count |
---|---|
206 | |
146 | |
97 | |
79 | |
69 |