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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Nandor
Helper I
Helper I

How to extract the values from two consecutive rows

Hi,

 

I have measurements of an equipment that produces tablets. The operator logs the value that the machine shows every 15 minutes. This value shows how many tablets were produced from the last reset.

I would like to see how many tablets were produced between two consecutive measurements.

 

My data looks like this:

 

Date&Time Measurement

 

Date&TimeMeasurement
01/06/2016 06:000
01/06/2016 06:3012000
01/06/2016 07:0022000
01/06/2016 07:3030000
01/06/2016 08:0044000
01/06/2016 08:3058000
01/06/2016 09:0072000
01/06/2016 09:3080000
01/06/2016 10:00102000

 

I would need to add a new column that shows every 30 minutes how many tablets were produced. My table should be like this:

 

Date&TimeMeasurementTablets produced between two measurements
01/06/2016 06:0000
01/06/2016 06:301200012000
01/06/2016 07:002200010000
01/06/2016 07:30300008000
01/06/2016 08:004400014000
01/06/2016 08:305800014000
01/06/2016 09:007200014000
01/06/2016 09:30800008000
01/06/2016 10:0010200022000

 

Thank you for the help.

Nandor

2 ACCEPTED SOLUTIONS
KGrice
Memorable Member
Memorable Member

Hi @Nandor. One way to do it would be to add an Index column to your dataset. While you're in the query editor, you can go to Add Column > Add Index Column. Then you can go to the Data view and Add New Column where you subtract the row where the index is one less the current row. Something like:

 

Column = TableName[Tablets] - LOOKUPVALUE(TableName[Tablets], TableName[Index], TableName[Index]-1)

 

Just be sure your data is sorted properly before adding the Index column!

 

View solution in original post

2 REPLIES 2
KGrice
Memorable Member
Memorable Member

Hi @Nandor. One way to do it would be to add an Index column to your dataset. While you're in the query editor, you can go to Add Column > Add Index Column. Then you can go to the Data view and Add New Column where you subtract the row where the index is one less the current row. Something like:

 

Column = TableName[Tablets] - LOOKUPVALUE(TableName[Tablets], TableName[Index], TableName[Index]-1)

 

Just be sure your data is sorted properly before adding the Index column!

 

Thank you!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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