Forum Discussion

Satya2804's avatar
Satya2804
Frequent Visitor
3 years ago

How to avoid circular dependency using previous row

Below is a sample data - first 3 columns are my inputs. Total Supply, Match and Long are my calculated columns. 

 

Total Supply = Current Quarter Supply + Previous quarter Long. Example Total Supply Q2 = 38 + 6 = 44

Match = Min(Outlook, Total Supply). Example Match Q2 = Min (41, 44) = 41

Long = Total Supply - Match. Example Long Q2 = 44-41 = 3

 

PowerBI gives a circular dependency error but Total Supply is actually using previous quarter Long and not current quarter long, so logically it is not circular. 

 

Can anyone help replicate the measures in PowerBI?

 

QuarterSupplyOutlookTotal SupplyMatchLong
Q1312531256
Q2384144413
Q34222452223
Q44522682246

8 Replies

  • Do you need this in Power BI? As a measure or calculated column?  Or can it be done in Power Query?

    • Satya2804's avatar
      Satya2804
      Frequent Visitor

      Was trying to solve for it in a measure, but even if it is a PowerQuery it works..

  • Hi,

    Do you have a proper Date column?  If yes, then share the download link of the PBI file.

    • Satya2804's avatar
      Satya2804
      Frequent Visitor

      Hi Ashish

      Yeah I can add a quarter end date as below:

      Quarter end dateQuarterSupplyOutlook
      31-03-2023Q13125
      30-06-2023Q23841
      30-09-2023Q34222
      31-12-2023Q44522
      • Ashish_Mathur's avatar
        Ashish_Mathur
        Super User

        Hi,

        That is definitely cicular logic.  I misread your question initially.