Forum Discussion

Joris_NL's avatar
Joris_NL
Icon for Helper III rankHelper III
1 year ago
Solved

Can't fix Circular dependency error working with Fabric's Semantic model

Hi, I created a Semantic model with Fabric and imported it into PowerBI (Get data - Power BI Semantic models). This works. The tables and relationships appear in PowerBI, and I can calculate measures. Then I change the storage from live to direct query (not to import). This step allows me to create calculated columns. But then the problem arises: in tables on the ‘one’ side of a ‘one-to-many’ relationship, RELATED cannot be used towards the ‘many’ side. The suggestions for columns do not appear when I type the formula. If I write it out anyway, I get a circular dependency error. What is going wrong?

 

Also tested the exact same tables and calculated columns on a direct API source (so not Fabric) with Import mode. Had no problems there.

 

'Import mode' would be fine for this dashboard, but I can't figure out how to change it. Bottom right text button isn't active.

 

 

 

  • My solution has been to change all Calculated columns which depended on RELATED, to m-code query columns. This also removed any circular dependencies. But it took a couple of hours and ended up with AI-generated m-code that's too complex for me to understand.

3 Replies

  • You're using a CC in 'PW SHV DossierworkFlow' that references a column in 'PW SHV Task', which in turn filters 'PW SHV DossierworkFlow'. In a Fabric semantic model (similar to Power BI tabular model), relationships are unidirectional, meaning that columns cannot reference measures or calculated columns that depend on them.

    Instead of using a CC, you can use a measure that calculates the minimum Startdatum actie dynamically:

    FirstStartDate =
    VAR KeyValue = SELECTEDVALUE('PW SHV DossierworkFlow'[WorkflowSleutel])
    RETURN
    CALCULATE(
    MIN('PW SHV Task'[Startdatum actie]),
    'PW SHV Task'[WorkflowSleutel] = KeyValue
    )

     

    If you must have it as a column you can create it in Power Query, just merge 'PW SHV Task' with 'PW SHV DossierworkFlow' using WorkflowSleutel and then computeMin(Startdatum actie) for each WorkflowSleutel.

    Last step expand and store the result in 'PW SHV DossierworkFlow'.

     

    • Joris_NL's avatar
      Joris_NL
      Icon for Helper III rankHelper III

      Hi Amerah,

      Big thanks for the quick response!

      First of all, yes, I can make these in M-code. But to illustrate my case I took the easiest column as an example. The other calculated columns depend on multiple conditions which would require a considerably higher number of query steps. However I get the impression that that would still be preferable.

      Second is that your solution works, but only for a single calculated column. If I want to add a second one, for instance a LastStartDate using MIN instead of MAX, I get the circular error again. I don't understand why. They use the same selectedvalue of WorkflowSleutel and the same range of Startdates of Task, just to calculate a min instead of max, right? I don't see the loop here.

  • My solution has been to change all Calculated columns which depended on RELATED, to m-code query columns. This also removed any circular dependencies. But it took a couple of hours and ended up with AI-generated m-code that's too complex for me to understand.