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!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hi Everyone,
I would like to replicate a calculation (quite simple) in Excel in a PowerBi file. I've tried several times but have an issue of circular dependency. I have not been able to break it so far so i would appreciate any help/ideas on how to model the Excel in PowerBi.
Here below the Excel file:
Many thanks in advance for your help!
Solved! Go to Solution.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Zc7BCQAhDAXRXv5ZMCbRxVqC/bexSFDj7vUdhjGDZKHMxIIEwkiGFoSdeqDHqXAwcVstPdQi1Ss2qXxiui9Wq/6+jvRbxgs=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, Inflow = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Inflow", Int64.Type}}),
#"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 0, 1, Int64.Type),
#"Added Custom" = Table.AddColumn(#"Added Index", "Capital Calc", each List.Accumulate({0..[Index]},[Roc=0,Cc=160],(state,current)=>[Roc = List.Min({state[Cc],#"Added Index"[Inflow]{current}}),Cc = state[Cc]-Roc]
)),
#"Expanded Capital Calc" = Table.ExpandRecordColumn(#"Added Custom", "Capital Calc", {"Cc", "Roc"}, {"Capital calc", "Roc"}),
#"Replaced Value" = Table.ReplaceValue(#"Expanded Capital Calc",each [Capital calc],each if [Index]>0 then #"Expanded Capital Calc"[Capital calc]{[Index]-1} else [Capital calc],Replacer.ReplaceValue,{"Capital calc"}),
#"Added Custom1" = Table.AddColumn(#"Replaced Value", "Realized gain", each if [Capital calc]=0 then [Inflow] else List.Max({0,[Inflow]-[Capital calc]}))
in
#"Added Custom1"
This is not just a circular dependency but also a reverse circular. Not something you want to do in Power BI that often.
How to use this code: Create a new Blank Query. Click on "Advanced Editor". Replace the code in the window with the code provided here. Click "Done".
Hello! Many thanks for the great answer/solution to my issue! 🙂
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Zc7BCQAhDAXRXv5ZMCbRxVqC/bexSFDj7vUdhjGDZKHMxIIEwkiGFoSdeqDHqXAwcVstPdQi1Ss2qXxiui9Wq/6+jvRbxgs=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, Inflow = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Inflow", Int64.Type}}),
#"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 0, 1, Int64.Type),
#"Added Custom" = Table.AddColumn(#"Added Index", "Capital Calc", each List.Accumulate({0..[Index]},[Roc=0,Cc=160],(state,current)=>[Roc = List.Min({state[Cc],#"Added Index"[Inflow]{current}}),Cc = state[Cc]-Roc]
)),
#"Expanded Capital Calc" = Table.ExpandRecordColumn(#"Added Custom", "Capital Calc", {"Cc", "Roc"}, {"Capital calc", "Roc"}),
#"Replaced Value" = Table.ReplaceValue(#"Expanded Capital Calc",each [Capital calc],each if [Index]>0 then #"Expanded Capital Calc"[Capital calc]{[Index]-1} else [Capital calc],Replacer.ReplaceValue,{"Capital calc"}),
#"Added Custom1" = Table.AddColumn(#"Replaced Value", "Realized gain", each if [Capital calc]=0 then [Inflow] else List.Max({0,[Inflow]-[Capital calc]}))
in
#"Added Custom1"
This is not just a circular dependency but also a reverse circular. Not something you want to do in Power BI that often.
How to use this code: Create a new Blank Query. Click on "Advanced Editor". Replace the code in the window with the code provided here. Click "Done".
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
| User | Count |
|---|---|
| 20 | |
| 10 | |
| 9 | |
| 4 | |
| 4 |
| User | Count |
|---|---|
| 33 | |
| 31 | |
| 19 | |
| 12 | |
| 11 |