Skip to main content
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.

Not applicable

Cyclic reference when calculating a Stock using its previous day result



I have a problem with a cyclic reference  trying to calculate the stock of a final inspection process.
Calculated Stock.png




*Day stock is the result of Production - Scrap - Wharehouse entry + Initial Stock
*If an inventory is loaded, that day Initial Stock = Inventory. If not, Previous day stock is needed


That leads to a cyclic reference I can't avoid.
Day Stock =Production - Scrap - Wharehouse entry + Previous day (Production - Scrap - Wharehouse entry + Previous second day (Production - Scrap - Wharehouse entry + Previous third day ... and so on)

How can I solve it?

Here is some sample data,

.PBI and Excel 



Ramiro Diz

Community Support
Community Support

Hi RamiroDiz, 

I think it is hard to calculate cycle reference in DAX. You need to create many measures for the previous day's value and the meausre will be beased on context, so it is hrad to get previous day's value(I complete a part of this). You might need to achieve this in other tools, then use this in PowerBI. Or you could try to ask other super users in forum for help.

Best Regards,
Zoe Zhi

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Not applicable


It's not posible to create infinite measures to get the value im wishing because I don't know how many days will pass since the last inventory.
Thats why I'm trying to generate a calculated column that brings the previous Day Stock if Inventory is empty. But I'm not able to get what I need.

Thanks for the answer,

Helpful resources

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


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.