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

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

Reply
bilyafamily
Regular Visitor

Subtract Current Row from Previous row in another column

Hello Team
I am new to dax kindly assist with a formula that will give me the result below. I want column A to alway have the value of the previous row in Column C.

Column AColumn BDifference
1,000.00100.00900.00
900.0050.00850.00
850.00200650.00
650.0050.00600.00

Thank you



 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

@bilyafamily 

 

You would need to add an index column to your data in Power Query.

add index.JPG

 

Column D =
VAR currentindex = Sheet1[Index]
RETURN
    IF (
        Sheet1[Column A] = BLANK (),
        CALCULATE (
            MIN ( Sheet1[Column C] ),
            FILTER ( Sheet1, Sheet1[Index] = currentindex - 1 )
        ),
        Sheet1[Column A] - [Column B]
    )

 

column d.JPG

 

Paul

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

@bilyafamily 

It seems you want to make change on Column A. But in Power BI, it is impossible to edit the original columns from databases, you can only create a new column that returns you expected value. In this case, we would need the original version of the your sample or show where are the 3 columns come from. 

Best, 
Paul

Original table looks like this

Column AColumn BColumn C
1,000.00100.00900.00
 50.00850
 200650.00
 50.00600.00

Expected Result should look this this

Column AColumn BColumn CColumn D
1,000.00100.00900.00900
 50.00850C1
 200650.00C2
 50.00600.00C3
Anonymous
Not applicable

@bilyafamily 

 

You would need to add an index column to your data in Power Query.

add index.JPG

 

Column D =
VAR currentindex = Sheet1[Index]
RETURN
    IF (
        Sheet1[Column A] = BLANK (),
        CALCULATE (
            MIN ( Sheet1[Column C] ),
            FILTER ( Sheet1, Sheet1[Index] = currentindex - 1 )
        ),
        Sheet1[Column A] - [Column B]
    )

 

column d.JPG

 

Paul

Thank you @Anonymous this works for me...I do appreciate
JarroVGIT
Resident Rockstar
Resident Rockstar

How does your data currently look like? Where does columnA first row come from? It is not impossible to add a column to a table that is based on the previous row, but we are going to need a little context. Based on your example, one could assume that the third column is calculated but you are asking for the first column (which would be necessary to have your data at all?).

Please elaborate so we can help you out:)




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




See the expected result below 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.