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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
Rob_Jackson
Frequent Visitor

Trouble reproducting an Excel function that uses the reseults from previous rows

Hi


Can anybody help me reproduce the following excel formula in a dax formula.  I can get the cumulative column working but cannot  retrieve the previous row data for the labour scrap calculation.Labour scrap rate calculation 2019-08-29 130345.jpg

Regards

 

Rob

2 REPLIES 2
v-eachen-msft
Community Support
Community Support

Hi @Rob_Jackson ,

 

Here is my sample data.

4-1.PNG

At first, you need to add an index column in the query editor.
Then you need to create a column like this.

Cost(Scrap Parts) =
VAR a =
    CALCULATE (
        SUM ( 'Table'[Cost] ),
        FILTER ( 'Table', 'Table'[Index] <= EARLIER ( 'Table'[Index] ) )
    )
RETURN
    'Table'[Scrap Rate] * a

Now you can get the result.


4-2.PNG

 

Best Regards,

Eads

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.

Hi

 

Thanks for offering a solution.  I think you are nearly there!  I recreated your table in excel and got slightly different results.  I don't think I was clear in the excel formula.  It needs to be incremental in summing all the previous Costs(Scrap Parts) Column.

I hope the table below with the excel formula is clearer.

Scrap RateCostCost (Scrap Parts) FORMULA
0.02100.20 =B3*C3
0.03200.91 =B4*SUM(D3,C3:C4)
0.04151.84 =B5*SUM(D3:D4,C3:C5)
0.0552.65 =B6*SUM(D3:D5,C3:C6)
0.1359.06 =B7*SUM(D3:D6,C3:C7)

 

Regards

 

Rob

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 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.