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
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
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.