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

Circular Dependency while creating multiple calculated columns

Hello experts,

 

I am able to calculate formula for sum of average of Actual Amount field and it was working fine. I tried to create the formula in the same way for variance and over variance fields but facing circular dependancy error.

 

ajay_techbrawn_0-1631015192730.png

Please find the below link for sample file for your reference. 

Sample.pbix - Google Drive 

 

Regards
Ajay

 

1 ACCEPTED SOLUTION
v-yetao1-msft
Community Support
Community Support

Hi @ajay_techbrawn 

Power BI does not allow two calculated columns that contain measures that are also based on the table .

In some scenarios, the DAX engine cannot build the dependency diagram. If two objects depend on each other, the engine does not know which one to compute first. If A depends on B and – at the same time – B depends on A, then it is impossible to compute A nor B. As soon as you compute A, this triggers the refresh of B. So you start refreshing B, wich in turn triggers the refresh of A. You are stuck in an infinite loop with no hope of ever getting the job done.

This situation, an infinite loop in the query plan, triggers the infamous circular dependency error. The only way to get rid of the problem is to avoid any circular dependencies. 

The following link can help you better understand circular dependency .

https://www.sqlbi.com/articles/understanding-circular-dependencies/ 

So you need change the behavior of the context transition by introducing ALLEXCEPT. When using ALLEXCEPT you can remove columns from the context transition, thus keeping in the dependency list only the required columns.

I made a little change to your second and third formulas .

Formula (Sum of Avg Over Variance) = CALCULATE(SUMX(VALUES(Sheet1[Plant]),[Avg Over Variance]),ALLEXCEPT(Sheet1,Sheet1[Plant],Sheet1[Material Group]))
Formula (Sum of Avg Variance) = CALCULATE(sumx(VALUES('Sheet1'[Plant]), 'Sheet1'[Avg Variance]),ALLEXCEPT(Sheet1,Sheet1[Plant],Sheet1[Material Group]))

The final result is as shown :

Ailsamsft_0-1631256047281.png

I have attached my pbix file ,you can refer to it .

 

Best Regards

Community Support Team _ Ailsa Tao

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

View solution in original post

4 REPLIES 4
v-yetao1-msft
Community Support
Community Support

Hi @ajay_techbrawn 

Power BI does not allow two calculated columns that contain measures that are also based on the table .

In some scenarios, the DAX engine cannot build the dependency diagram. If two objects depend on each other, the engine does not know which one to compute first. If A depends on B and – at the same time – B depends on A, then it is impossible to compute A nor B. As soon as you compute A, this triggers the refresh of B. So you start refreshing B, wich in turn triggers the refresh of A. You are stuck in an infinite loop with no hope of ever getting the job done.

This situation, an infinite loop in the query plan, triggers the infamous circular dependency error. The only way to get rid of the problem is to avoid any circular dependencies. 

The following link can help you better understand circular dependency .

https://www.sqlbi.com/articles/understanding-circular-dependencies/ 

So you need change the behavior of the context transition by introducing ALLEXCEPT. When using ALLEXCEPT you can remove columns from the context transition, thus keeping in the dependency list only the required columns.

I made a little change to your second and third formulas .

Formula (Sum of Avg Over Variance) = CALCULATE(SUMX(VALUES(Sheet1[Plant]),[Avg Over Variance]),ALLEXCEPT(Sheet1,Sheet1[Plant],Sheet1[Material Group]))
Formula (Sum of Avg Variance) = CALCULATE(sumx(VALUES('Sheet1'[Plant]), 'Sheet1'[Avg Variance]),ALLEXCEPT(Sheet1,Sheet1[Plant],Sheet1[Material Group]))

The final result is as shown :

Ailsamsft_0-1631256047281.png

I have attached my pbix file ,you can refer to it .

 

Best Regards

Community Support Team _ Ailsa Tao

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

amitchandak
Super User
Super User

@ajay_techbrawn , you are trying to measure in a column. That will not work. You have create a measure or create a column using columns only

 

example measure

calculate(sumx(VALUES('Sheet1'[Plant]), 'Sheet1'[Avg Variance]), allselected()) 

Hi @amitchandak ,

 

I have tried the formula given by you but it is not working as per my requirement. 

 

I have 3 fields Actual Amount, Variance and Over Variance. 
First I have to calculate average of Actual Amount with respect to material wise and I am able to do that using measure.

Avg Actual Amount = CALCULATE(AVERAGE(Sheet1[Actual Amount]), FILTER(ALLSELECTED(Sheet1), Sheet1[Plant] = MAX(Sheet1[Plant]) && Sheet1[Material Group] = MAX(Sheet1[Material Group])))

 

Then I have to display the subtotals of that average field as SUM. I am able to do that also for Actual Amount using a column as shown below in the last column.

Formula (Sum of Avg Actual Amount) = sumx(VALUES('Sheet1'[Plant]), 'Sheet1'[Avg Actual Amount])

ajay_techbrawn_0-1631029917887.png

Till here it was good!

In the similar way, I have to calculate average and Sum of average for Variance and Over Variance fields.
I am able to calculate average using measures but not able to create Sum of average using columns. 
I am facing Circular dependency while calculating the sum of average. 

ajay_techbrawn_1-1631030364280.png

 

How can I solve this issue? Could you please do and show.


Regards
Ajay

Hello experts,

 

Could anyone please look into the issue and provide your inputs to resolve.!

 

Regards

Ajay

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.