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
Anonymous
Not applicable

Decreasing value in the column

Hello,

 

I need to create a new column in Power Query, so that I have a starting ammount and the values in the new column are created by substracting using the values from the existing columns.

 

Exampl:

 

starting amount (costs) = 10 000 000

 

Row NumYear NumSavingsExpansesDeclining Costs
12018956 547

25 623

= 10 000 000 - Savings 1 + Expanses 1
22019966 47126 721= Declining Costs 1 - Savings 2 + Expanses 2
32020926 31924 834= Declining Costs 2 - Savings 3 + Expanses 3
     

 

Can you help me? 🙂

 

 

1 ACCEPTED SOLUTION
Jakinta
Solution Sage
Solution Sage

Here is one of many possible ways to do it.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Jcu7DQAxCAPQVRB1ivBPZkHsv8YFrrLkZ2ci4ULedF5cczCNLgycBWsl8u+33R005uAQTOMyzrv91TJLVjiiWPUB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Row Num" = _t, #"Year Num" = _t, Savings = _t, Expanses = _t]),
    #"Replaced Value" = Table.ReplaceValue(Source," ","",Replacer.ReplaceText,{"Savings", "Expanses"}),
    ChangedType = Table.TransformColumnTypes(#"Replaced Value",{{"Savings", type number}, {"Expanses", type number}, {"Row Num", Int64.Type}}),
    #"Added Custom" = Table.AddColumn(ChangedType, "Declining Costs", each let s=List.Sum (List.Range(ChangedType[Savings],0,[Row Num]) ), e=List.Sum ( List.Range(ChangedType[Expanses],0,[Row Num]) ) in 10000000 - s + e)
in
    #"Added Custom"

View solution in original post

1 REPLY 1
Jakinta
Solution Sage
Solution Sage

Here is one of many possible ways to do it.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Jcu7DQAxCAPQVRB1ivBPZkHsv8YFrrLkZ2ci4ULedF5cczCNLgycBWsl8u+33R005uAQTOMyzrv91TJLVjiiWPUB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Row Num" = _t, #"Year Num" = _t, Savings = _t, Expanses = _t]),
    #"Replaced Value" = Table.ReplaceValue(Source," ","",Replacer.ReplaceText,{"Savings", "Expanses"}),
    ChangedType = Table.TransformColumnTypes(#"Replaced Value",{{"Savings", type number}, {"Expanses", type number}, {"Row Num", Int64.Type}}),
    #"Added Custom" = Table.AddColumn(ChangedType, "Declining Costs", each let s=List.Sum (List.Range(ChangedType[Savings],0,[Row Num]) ), e=List.Sum ( List.Range(ChangedType[Expanses],0,[Row Num]) ) in 10000000 - s + e)
in
    #"Added Custom"

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.

Top Solution Authors