Forum Discussion

MSUSPARTAN's avatar
MSUSPARTAN
Frequent Visitor
4 years ago
Solved

Circular Reference Error help

I have a formula I added in a column (cAsphalt interm) and it runs fine.  When I copy paste the exact same formula to a second column (column), I get a circular reference error?     the error:    <...
  • mahenkj2's avatar
    4 years ago

    Hi MSUSPARTAN ,

     

    I made sample data to simulate the problem and yes, the problem is there with this formula!

     

    BoMtQtyRequiredcWhse ItemcComponentcAsphalt intermcAsphalt interm1

    10a3abcd10 
    5aZabcd  
    20b2PBabcd20 
    4cd  
    12d2PBABCs12 

     

    The duplicated column show error with the formula you mentioned.

     

    Reason looks to be use of CALCULATE in calculated column and Context transition. In this case, second column cal not be calculated untill the first is calculated.

     

    This is well explained at below link:

     

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

     

    Marco and Russo are expert of the topic, it is best to learn from thier original text.

     

    Some key text I mention here for reference:

     

    Let us start analyzing the first scenario: context transition in calculated columns. If you do not pay attention to circular dependencies, you cannot create more than one calculated column in a table – if the formula of the column contains CALCULATE anywhere. Indeed, CALCULATE in a calculated column performs a context transition and makes that column dependent on all the columns in the table. If two such columns exist, they depend on each other. Therefore, you experience circular dependency only once you have created the second column.
    
    The correct solution to avoid this is to restrict the list of columns that the calculated column depends on, by using ALLEXCEPT or REMOVEFILTERS and keeping only the table’s primary key. If the table has no primary key, then using CALCULATE in a calculated column is dangerous; this is because context transition is likely to produce unexpected results.

     

    Please modify the formula suitably.

     

    Hope it helps.