Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago

A circular dependency was detected

I have 2 tables. In one - the product (status by shift), in the other - waste on this product (pw by shift).
In the product table, I use a function to get the withdrawal code in this product. I take all the waste and choose the one with the greatest length.
Formula:

 

Fault code = 
VAR auxT_ =
    CALCULATETABLE (
        'pw by shift',
        TREATAS (
            CALCULATETABLE (
                SUMMARIZE (
                    'pw by shift',
                    'pw by shift'[Production Order],
                    'pw by shift'[Runup Index],
                    'pw by shift'[Lane]
                )
            ),
            'status by shift'[Production Order],
            'status by shift'[Runup Sequence],
            'status by shift'[Lane]
        )
    )
VAR maxLenT_ =
    TOPN ( 1, auxT_, [Length], DESC )
RETURN
    MAXX ( maxLenT_, [Fault code] )

 


However, if I try to use this value in the formula of an adjacent column in the same table, I get an error about a cyclic formula.

Why? For each row from the product table, I take the value from the waste table. How can changes in the product table affect the result?

 

NewColumn contains the formula NewColumn = 'status by shift' [Fault code] and this already causes a failure.

 

1 Reply

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi  Anonymous  ,

    I created the data myself, simulated it again, and it can be displayed:

    Column =
    CALCULATE(SUM('Table'[amount]),FILTER('Table','Table'[Month]=EARLIER('Table'[Month])))
    

    My guess is that the formula in your calculated column[Fault_code] caused the circular dependency.

     

    can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

     

    Reasons for circular dependence:

    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 is a link about circular dependencies, I hope it will help you:

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

     

    Best Regards,

    Liu Yang

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