Forum Discussion

Live_Mace's avatar
Live_Mace
Frequent Visitor
2 years ago

Avoid Circular Dependency Error With Dependent Measures

I'm a novice with dax, so forgive me if this is a stupid question...

My table looks like this:

 

PeriodBIProdDemandEI
2023103200300022004000
202311400050003200 
202312 40004520 
202401 60004225 
202402 75006200 

 

This is what I want:

Period

BIMeasureEIMeasureProdDemandProj EIProj BI
202310IF BI is blank, Proj BIIF EI is blank, Proj EI30002200(BIMeasure+Prod)-DemandProj EI of Period:202309
202311IF BI is blank, Proj BIIF EI is blank, Proj EI50003200(BIMeasure+Prod)-DemandProj EI of Period:202310
202312IF BI is blank, Proj BIIF EI is blank, Proj EI40002200(BIMeasure+Prod)-DemandProj EI of Period:202311
202401IF BI is blank, Proj BIIF EI is blank, Proj EI60002352(BIMeasure+Prod)-DemandProj EI of Period:202312
202402IF BI is blank, Proj BIIF EI is blank, Proj EI75006200(BIMeasure+Prod)-DemandProj EI of Period:202401

I keep getting a circular reference error, which I understand, but I can't seem to find a way to avoid it.

2 Replies

  • vanessafvg's avatar
    vanessafvg
    Community Champion

    can you please share your code?

     

    one thing i would suggest is that if you can create the logic for these columns in power query, then do that there, but it all depends on how you are deriving this information.

    • Live_Mace's avatar
      Live_Mace
      Frequent Visitor
      Proj_BI = 
             CALCULATE(
                 [Proj_EI],
                 FILTER(
                     ALL('Table'[Period]),
                     'Table'[Period] = MAX('Table'[Period]) - 1
                 )
             )
      Proj_EI = ([Proj_BI] + [Prod]) - [Demand]
      
      BIMeasure = IF(ISBLANK(SUM('Table'[BI])), [Proj_BI], SUM('Table'[BI]))
      
      EIMeasure = IF(ISBLANK(SUM('Table'[EI])), [Proj_EI], SUM('Table'[EI]))

      This is the code.

      The calculation is only required at this level of aggregation, on the power query side the data is more granular.