cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
divo
Helper II
Helper II

How to Overcome a Circular Dependency was Detected

Hi All,

 

This is my first time facing an issue like this. Basically I am attempting to perform the computation below:

 

My Measures (NB: All my measures are in the table MeasureFuel):

 

daily_closing_useful_stock = 'MeasureFuel'[daily_closing_global_fuel_stock] - sum(Parameters[Dead stock (Liter)]) /* Final Result */

 

Intermediate results

 

daily_closing_global_fuel_stock = 'MeasureFuel'[opening_global_fuel_stock] + sum('Daily Input'[Daily Delivery (Liter)]) - sum('Daily Input'[Daily Consumptions (Liter)])

 

Intermediate results

 

opening_global_fuel_stock = if ('MeasureFuel'[daily_closing_fuel_stock_pd] <> 0, 'MeasureFuel'[daily_closing_fuel_stock_pd], sum(Parameters[Opening Global fuel Stock (Liter)])

 

Intermediate results

 

daily_closing_global_fuel_stock_pd = CALCULATE( 'MeasureFuel'[daily_closing_global_fuel_stock], PREVIOUSDAY(DimDate[Date]))

 

My issue is this: When I try to save the measure opening_global_fuel_stock, i get the error "A circular dependency was detected"

 

How can I fix this??

5 REPLIES 5
v-xicai
Community Support
Community Support

Hi  @divo ,

 

Does that make sense? If so, kindly mark the proper reply as a solution to help others having the similar issue and close the case. If not, let me know and I'll try to help you further.

 

Best regards

Amy

 

Hi,

v-xicai
Community Support
Community Support

Hi @divo ,

 

There is a good description for circular dependencies: https://www.sqlbi.com/articles/understanding-circular-dependencies/.

 

It does not allow to have two calculated columns that contain measures that are also based on that table.   As a workaround, you may try to convert these into measures instead of column.

 

You can refer to the similar case: "A circular Dependency was detected" error while creating a calculated column.

 

Best Regards,

Amy

 

Community Support Team _ Amy

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

edhans
Super User III
Super User III

Are you sure those are measures? Some of those look like calculated columns, and it is easy to get into a circular dependency in a calculated column.

 

You can greatly avoid much of this by calculating those columns in Power Query and bring them in there if possible. If not, you have to understand how CALCULATE() actually uses every column behind the scenes to do its work when used in a calculated column, so if the calculated column references columns A and B, it really references all columns when determining row context, then you do another calculated column with CALCULATE, it references all existing columns, but your first column you created now refrences this second one too, and you get a circular dependency. It can get complex.

 

You can read more details here, or you can see Chapter 5 of "The Definitive Guide to DAX 2nd Edition" if you really want to dig in to this.

 

 



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

Hi @edhans ,

 

Thanks for your input

 

Those are measures. All my measures are in the table MeasureFuel.

 

Regards,

 

Divo

edhans
Super User III
Super User III

Ok. The standard way to refer to measures is just [MeasureName] with no table. Measures can be anywhere. Unlike TableName[FieldName] would refer to a specific field in a table. That is why I thought those were calculated columns. Table names in formulas refer to specific fields.

 

[daily_closing_global_fuel_stock_pd] (1) is referring to [daily_closing_global_fuel_stock] (2) and (3), which is referring to [opening_global_fuel_stock] (4) and (5), which is referring back to [daily_closing_global_fuel_stock].

 

That is where your circular reference error is coming from I think.

20191117 05_49_22-Re_ How to Overcome a Circular Dependency was Dete... - Microsoft Power BI Commu.png

 

 



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

Helpful resources

Announcements
PBI User Groups

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

April Update

Check it Out!

Click here to read more about the April 2021 Updates!

secondImage

The largest Power BI virtual conference

100+ sessions, 100+ speakers, Product managers, MVPs, and experts. All about Power BI. Attend online or watch the recordings.

secondImage

Experience what’s next for Power BI

See the latest Power BI innovations, updates, and demos from the Microsoft Business Applications Launch Event.