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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
Anonymous
Not applicable

Replicate excel formula - recursive substraction

Hi there. I am trying to replicate excel formula in power BI DAX. I have date column(A) with date, progress column(B) with integer, left column(C) with integer. This meant to be project progress monitoring tool. So the team is starting with 100k instances to process and on each day they do certain progress, so in the cell C2 = 100000-B2,but starting from C3 = C2 - B3, C4 = C3 - B4 and so on...

 

Help will be appreciated.

Thanks,

Michal

 

 

 

 

 

1 REPLY 1
ImkeF
Community Champion
Community Champion

Hi @Anonymous ,

if you're serious about performance here, I'd recommend this approach:

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjDUByIjAyMDJR0lQwMQUIrVgYgbIcThYsYwMSOEmAlMzBghZopFrxmy3lgA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [date = _t, progress = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"date", type date}, {"progress", Int64.Type}}),
    ListToAccumulate =  List.Buffer(#"Changed Type"[progress]),
    AccumulateColumn = List.Generate( ()=>
        [Result = List.First(ListToAccumulate), Counter = 1 ],
        each [Counter] <= List.Count(ListToAccumulate),
        each [
                Result = [Result] - ListToAccumulate{[Counter]},
                Counter = [Counter] + 1
        ],
        each [Result]
        
    ),
    Custom2 = Table.FromColumns(Table.ToColumns( #"Changed Type") & {AccumulateColumn}, Table.ColumnNames(#"Changed Type") & {"Left"})
in
    Custom2

 

Copy the code, paste it into the advanced editor of a new query and follow the steps.

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.