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
hardusjan123
Frequent Visitor

List.Generate - Simple addition and subtraction, with Closing balance used as Opening balance

Hi All, 

 

I am struggling to create a function that will add and subtract multiple columns in 1 line, and use the first Line's SOH as opening balance, subtract Consumption and add Incoming orders.Next line's opening balance is the previous line's closing balance. All data is in 1 table, but needs to do this till it reaches a certain number (31 - days) for all 3 products (X,Y and Z)

Closing Balance (n) = SOH - Consumption + Incoming Orders

Opening Balance (n+1) = SOH - Consumption + Incoming Orders

 

When testing this using sample numbers it works, but when trying to add solve the function and replace it with the data in the table, i get an error stating "Formula.Firewall: Query 'Dates' (step 'Invoked Custom Function') references other queries or steps, so it may not directly access a data source. Please rebuild this data combination.". Is there anyone that can try to assist or shed some light on what I am doing incorrectly. Very new to working with Functions in Power Query.

 

Many Thanks.

 

Regards 

hardusjan123_1-1682425183662.png

 

 

 

hardusjan123_0-1682425144697.png

 

1 REPLY 1
hardusjan123
Frequent Visitor

= List.Generate( () =>
[Day= 1 , SOH = MySOH, Consumption = MyConsumption, IncomingOrders= MyIncomingOrders ],
each [Day] <= #"Counted Rows",
each [Day = [Day]+1 ,Consumption = [Consumption], IncomingOrders = [IncomingOrders], SOH= [SOH]-[Consumption]+[IncomingOrders]],
each [SOH]) - My current code for List.Generate if this will help...

 

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.