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

Top Solution Authors
Top Kudoed Authors