Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
SajjadMousavi
Helper II
Helper II

Circular reference error in calculated column when adding second one

Hi.

I have a table and have added this calculated column with no problem:

 

RunningTotalTransWeight = CALCULATE(SUM(InventTrans[TransWeight]), InventTrans[TransDate] <= EARLIER(InventTrans[TransDate]))
 
Now I want to add another one with this code:
 
RunningTotalFinancialCostAmount = CALCULATE(SUM(InventTrans[FinancialCostAmount]), InventTrans[TransDate] <= EARLIER(InventTrans[TransDate]))
 
When I want to save it, I receive this error:
 
A circular dependency was detected: InventTrans[RunningTotalFinancialCostAmount], InventTrans[RunningTotalTransWeight], InventTrans[RunningTotalFinancialCostAmount].
 
Codes for both columns are almost the same, just the field which calculation is based on differs. Why this happens?
 
Thanks in advance.
1 ACCEPTED SOLUTION
MahyarTF
Memorable Member
Memorable Member

Hi, 

As I saw in your codes, you are using the dependency code and you need to change your code to fix the issue.

please have a look at the below article :

https://www.sqlbi.com/articles/avoiding-circular-dependency-errors-in-dax/

Mahyartf

View solution in original post

3 REPLIES 3
SajjadMousavi
Helper II
Helper II

Thank you both @MahyarTF and @MFelix . According to links you provided, I added an index column and applied ALLEXCEPT on it to change Power BI behavior.

MahyarTF
Memorable Member
Memorable Member

Hi, 

As I saw in your codes, you are using the dependency code and you need to change your code to fix the issue.

please have a look at the below article :

https://www.sqlbi.com/articles/avoiding-circular-dependency-errors-in-dax/

Mahyartf
MFelix
Super User
Super User

Hi @SajjadMousavi,

 

What's is hapenning is related with the context transiction

 

Please check this blog post with a detailed explanation

 

https://community.powerbi.com/t5/Community-Blog/Circular-Dependency-between-Calculated-Columns-in-a-...

 

To what I can understand you want to calculate cumulatives values is this correct?  In this case I advise for you to use a measure instead of calculated columns they will not be dependent on this context transiction and will be much more flexible in the use. 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.