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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
shamim20
New Member

Calculated column based on two other column

Hello altruists, 

Need some help here.

I have 3 columns of data with millions of rows ( File, record and Time). Each file may have multiple records. Would like to create 4 new columns calculating time difference between two records ( 0 to 1, 1 to 2 and so on ) for each file. Expected outputs are showed in last 4 columns ( Record_0to1 and so on) . Would appreciate any help with this. Thanks

 

 

FileRecordTimeRecord_0to1Record_1to2Record_2to3Record_3to4
A01001015540
A1901015540
A2751015540
A3701015540
A4301015540
B020020301020
B118020301020
B215020301020
B314020301020
B412020301020
C040050406050
C135050406050
C231050406050
C325050406050
C420050406050
1 ACCEPTED SOLUTION
parry2k
Super User
Super User

@shamim20 add four measures, here is example of 0 - 1

 

Diff 0 to 1 = 
VAR __filter = ALLEXCEPT ( 'Table', 'Table'[File] )
VAR __valStart = CALCULATE ( [Sum], __filter, 'Table'[Record] = 0 )
VAR __valEnd = CALCULATE ( [Sum], __filter, 'Table'[Record] = 1 )
RETURN
__valStart  - __valStart

 

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

3 REPLIES 3
parry2k
Super User
Super User

@shamim20 add four measures, here is example of 0 - 1

 

Diff 0 to 1 = 
VAR __filter = ALLEXCEPT ( 'Table', 'Table'[File] )
VAR __valStart = CALCULATE ( [Sum], __filter, 'Table'[Record] = 0 )
VAR __valEnd = CALCULATE ( [Sum], __filter, 'Table'[Record] = 1 )
RETURN
__valStart  - __valStart

 

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Hi,

Thanks for your reply. What are you referring to as sum here >>

[Sum]

 

This is what I ahve at the end

 

Diff 0 to 1 = 
VAR __filter = ALLEXCEPT ( 'Table', 'Table'[File] )
VAR __valStart = CALCULATE ( SUM(TABLE.Time), __filter, 'Table'[Record] = 0 )
VAR __valEnd = CALCULATE ( [SUM(TABLE.Time),__filter, 'Table'[Record] = 1 )
RETURN
__valStart  - __valStart

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.