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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
Rallmo
Helper I
Helper I

Get data from next/previous row

Hi

 

I have a problem that I cant figure out how to solve, wasn't sure on where this is best solved (DAX or M-code) so therefore I put it under Desktop. 🤷‍

 

In our ticketing system I want to calculate the actual time a ticket is open. I have the requestDate when the ticket is created and the completionDate when we consider the ticket completed. Between those two dates its easy to just do a Datediff and be done with it. But I want to exclude the period when we are waiting for information from the end user. I have the start time for that under onHoldDate but I dont have the date and time for when the ticket is active again and we should stop considering the ticket as On Hold. 

 

So for every time the ticket is On Hold I would like to collect the timeStamp information from the following row and store it in a separate column preferably.

 

Do I need a index column to reference? Would you solve this is Power Query or with DAX? Is there a best practice I should use?

 

Here's a sample of what my data looks like.

 

timeStamp  ticketIdrequestDatecompletionDateonHoldDatestatusIdStatus
2023-07-20 14:24e17297772023-07-20 14:24  225ded26Logged
2023-07-25 12:35e17297772023-07-20 14:24 2023-07-21 07:434fbc9b46Waiting for user
2023-07-26 08:00e17297772023-07-20 14:24  1ee72955In progress
2023-07-26 08:00e17297772023-07-20 14:24  1ee72955In progress
2023-07-26 10:25e17297772023-07-20 14:24  1ee72955In progress
2023-07-26 10:26e17297772023-07-20 14:24  1ee72955In progress
2023-07-26 11:33e17297772023-07-20 14:24 2023-07-26 11:334fbc9b46-82efWaiting for user
2023-07-27 14:07e17297772023-07-20 14:24  1ee72955In progress
2023-07-27 14:08e17297772023-07-20 14:24  1ee72955In progress
2023-07-27 14:30e17297772023-07-20 14:24  1ee72955In progress
2023-07-28 07:36e17297772023-07-20 14:24 2023-07-28 06:554fbc9b46Waiting for user
2023-07-28 07:37e17297772023-07-20 14:242023-07-28 07:37 ca371597Completed
2023-07-28 07:37e17297772023-07-20 14:242023-07-28 07:37 ca371597Completed
2023-08-02 07:37e17297772023-07-20 14:242023-07-28 07:37 4350a7ddClosed

 

Thanks in advance!

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Rallmo , Index can help.

 

One of the way to get diff , say for timestamp

 

New  Column =

var _max = maxx(filter(Table, [TicketID] = earlier([TicketID])  && [timestamp] <earlier( [timestamp]) ), [timestamp])

return

datediff(_max , [timestamp], second)

 

Power BI DAX- Earlier, I should have known Earlier: https://youtu.be/CVW6YwvHHi8
https://www.youtube.com/watch?v=cN8AO3_vmlY&t=17820s

 

 

Power Query- Index Column: https://youtu.be/NS4esnCDqVw

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

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@Rallmo , Index can help.

 

One of the way to get diff , say for timestamp

 

New  Column =

var _max = maxx(filter(Table, [TicketID] = earlier([TicketID])  && [timestamp] <earlier( [timestamp]) ), [timestamp])

return

datediff(_max , [timestamp], second)

 

Power BI DAX- Earlier, I should have known Earlier: https://youtu.be/CVW6YwvHHi8
https://www.youtube.com/watch?v=cN8AO3_vmlY&t=17820s

 

 

Power Query- Index Column: https://youtu.be/NS4esnCDqVw

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

Thanks for your response @amitchandak. My post got marked as spam so I forgot to follow up here. I solved it with an index, but I'll for sure try your solution aswell.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.