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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

work with offset rows

Hello,

 

i have a machina which save time data in a base at each time we change the product (column 3). But sometimes the machina have a bug and write a rows without reason.

So i have this data, but i want this :

 

vadim_g_0-1663680314504.png

 

You will see that the End Time is the same than the Start Time at the next row. But i want merge the data on one row if the product number is the same to have the good duration for each product.

 

Thanks a lot...

 

horodatage debuthorodatage finproduit
01/01/2022 06:00:0001/01/2022 08:00:00FL1004
01/01/2022 08:00:0001/01/2022 12:00:00FL1004
01/01/2022 12:00:0002/01/2022 08:00:00FL1004
02/01/2022 08:00:0002/01/2022 14:00:00FV0937
02/01/2022 14:00:0003/01/2022 09:00:00FN1199
03/01/2022 09:00:0003/01/2022 11:00:00FN1199
03/01/2022 11:00:0003/01/2022 14:00:00FV0937

 

 

 

 

1 REPLY 1
Greg_Deckler
Super User
Super User

@Anonymous Create a Group By step in Power Query Editor? Alternatively in DAX you can work with offset rows using something like MTBF. See my article on Mean Time Between Failure (MTBF) which uses EARLIER: http://community.powerbi.com/t5/Community-Blog/Mean-Time-Between-Failure-MTBF-and-Power-BI/ba-p/339586.
The basic pattern is:
Column = 
  VAR __Current = [Value]
  VAR __PreviousDate = MAXX(FILTER('Table','Table'[Date] < EARLIER('Table'[Date])),[Date])

  VAR __Previous = MAXX(FILTER('Table',[Date]=__PreviousDate),[Value])
RETURN
  __Current - __Previous



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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