Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Circular dependencies how to solve?

Hi All,

I have a simple scenario where one measure gets values for a previous year and another gets the values for the current year then they get summed.

 

For example below I have a simple table named company with a slicer on year column.

Year    sales

2020  1000

2019  500

 

In total we have three measures. Current year sales, Previous year sales and total for the two years.

So the first measure gets the current year sales since the slicer is set to 2020.

The previous year sales we have another measure which is the sales for the current year minus 1.

Finally, we get the two years sales by summing the two measures.

 

So far the third measure for the two years of sales is throwing an error about circular dependency.

 

Any thoughts?

Thanks!!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Ok I solved the issue after I white boarded the problem. I added another measure that took the previous biennium balance measure and subtracted the current biennium total. I got no error in the new measure.

 

Thanks Everyone!

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Ok I solved the issue after I white boarded the problem. I added another measure that took the previous biennium balance measure and subtracted the current biennium total. I got no error in the new measure.

 

Thanks Everyone!

Greg_Deckler
Super User
Super User

Circular dependencies are notoriously difficult to solve. The more information the better, like formulas for example.

 

Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Hi Greg you are right. I just started looking at articles on this issue in general. I usually try to supply a simple version of what I am doing then I take an answer and scale it up so to speak to the actual design.

So the table actaully looks like

Slicer is BIENNIUM table below called transactions

Previous Biennium     FM01        FM02       FM 03 ...     FM12          FMTotal       Ending Balance

 1,0000                                10.00       20.00          30.0             40.00          100.00          1,100.00

 

So there are three measures as mentioned before

1 - Previoius Biennium

2 - FM Total

3- Total Costs

 

I got the circular dependenciy error when trying to put in the Previous BM total measure into the Ending Balance to get the totals

Note: I did not put in all 26 FM's (13 FM's for each year) into this response but you get the idea I hope.

 

So the measure for the Previous Biennium Balance:

MeasurePBNTotal = VAR
selectedYearBMMinus1 = if( HASONEVALUE('Transactions'[BIENNIUM]),
    FIRSTNONBLANK('Transactions'[BIENNIUM],'Transactions'[BIENNIUM]),
    BLANK() )-1
Return
    CALCULATE(
        'Transactions'[MeasureEndingBalance],
        'Transactions'[BIENNIUM] = selectedYearBMMinus1 )
 
The Measue for the FMTotal:
MeasureFMTotal = [MeasureFM01]+[MeasureFM02]+[MeasureFM03]+[MeasureFM04]
 
Finally for the Ending Balance Measure adds the first year FM's to the second year FM's:
MeasureEndingBalance = SUMX('Transactions',[MeasureFMTotal] + [MeasureFM13]+[MeasureFM14]+[MeasureFM15]+[MeasureFM16]+[MeasureFM17]+[MeasureFM18])
parry2k
Super User
Super User

@Anonymous do you have calendar dimension in your model from where you are using year or it is part of main table?



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

Good question.

I work in financials right now and instead of a date field it is actually a Biennium field or numbers. The other fields are Fiscal Months which I turned into numbers to replace 01, 02, 03... with 1,2,3 but I did not want to make the example too complicated.

So to make the problem hopefully more simple

 

Biennium   costs

20                 1000

21                 50

 

I hope that helps.

 

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.