Forum Discussion
Power Query - How to Calculate Time Difference with Previous Row & Adjacent Column?
- 2 years ago
Thanks for your clear question and example data. I wish all members did that!
There are a few methods you can use, but try this one ....
Create a measure tp get the previous stop time
Previous stop time =VAR mystart = SELECTEDVALUE(Microchips[Start time])RETURNCALCULATE(MAX(Microchips[Stop time]),ALL(),Microchips[Stop time] <= mystart)Then create a measure to get the idle tile between the batches.
You can do this in any unit of measure, but I have used minutes in this exampleMinutes idle =DATEDIFF([Previous stop time],SELECTEDVALUE(Microchips[Start time]),MINUTE)Thanks for reaching out for help.
I put in a lot of effort to help you, now please quickly help me by giving kudos.
Remember we are unpaid volunteers and here to coach you with Power BI and DAX skills and techniques, not do the users job for them. So please click the thumbs up and accept as solution button.
If you give someone a fish then you only give them one meal, but if you teach them how to fish then they can feed themselves and teach others for a lifetime. I prefer to teach members on this forum techniques rather give full solutions and do their job. You can then adapt the technique for your solution, learn some DAX skills for next time and soon become a Power BI Super User like me.
One question per ticket please. If you need to extend your request then please raise a new ticket.
You will get a quicker response and each volunteer solver will get the kudos they deserve. Thank you !
If you quote @speedramos in yout tickers then I will then received an automatic notification, and will be delighted to help you if you click the humbs up and accept as solution button. Thank you. - 2 years ago
For your reference.
Step 1: I load the data with Power Query Editor twice as 'DATA_01' and 'DATA_02'.
Step 2: I add 'Index+1' column to 'DATA_02'.
Step 3: I merge 'DATA_01' query and 'DATA_02' query with 'Index' and 'Index+1'.
Step 4: I expand 'DATA_02'.
Step 5: I add 'Elapsed Time in Minutes' column to 'DATA_01' in Power BI Desktop.
Elapsed Time in Minutes = DATEDIFF([DATA_02.STOP TIME],[START TIME],MINUTE)
Thanks for your clear question and example data. I wish all members did that!
There are a few methods you can use, but try this one ....
Create a measure tp get the previous stop time
You can do this in any unit of measure, but I have used minutes in this example
Thanks for reaching out for help.
I put in a lot of effort to help you, now please quickly help me by giving kudos.
Remember we are unpaid volunteers and here to coach you with Power BI and DAX skills and techniques, not do the users job for them. So please click the thumbs up and accept as solution button.
If you give someone a fish then you only give them one meal, but if you teach them how to fish then they can feed themselves and teach others for a lifetime. I prefer to teach members on this forum techniques rather give full solutions and do their job. You can then adapt the technique for your solution, learn some DAX skills for next time and soon become a Power BI Super User like me.
One question per ticket please. If you need to extend your request then please raise a new ticket.
You will get a quicker response and each volunteer solver will get the kudos they deserve. Thank you !
If you quote @speedramos in yout tickers then I will then received an automatic notification, and will be delighted to help you if you click the humbs up and accept as solution button. Thank you.