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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Alizee
Frequent Visitor

Count Distinct Values by IDs of another table but it creates circular dependency

Hello,

 

I have two tables linked by a one-to-many relationship:

Candidates with their ID as primary key and Candidate_Reference that is connected to it through this ID.

The Candidates table regroup all my candidates information and Candidate_Reference regroup infomation about their references if they have any. Therefore, the candidates in Candidates can not appear in Candidate_Reference if they do not have any references however, for those that appear as they have references, I would like to count the number of references they individually have. To do so, I was planning to DistinctCount the ID of the references for each candidate.id as each reference has a unique ID as well.

circ1.PNGThe candidate_reference tableThe candidate_reference table

Originally, I created a Calculated Column in the Candidate Table to compute it as I would then have a count for every unique Candidate ID in the table. I also thought best to have the result there since I would need to include it in my dashboard later with other values from the Candidate Tables.

This was the formula I used:

Reference Count = CALCULATE(DISTINCTCOUNT(candidate_reference[_id]),ALLSELECTED(candidate[id]))

Upon checking the column, I could see that the results were exactly as expected with the right count for every candidate.

circ6.PNG

The next step for me was to include it in the report after some conditional formating steps but they didn't work out and returned a Circular Dependancy Error.

circ5.PNG

I tried a few different variations, creating measures instead of calculated columns and so on and using different functions but the result was never right nonetheless.

 

This was the expected result in my dashboard (after another conditional formating step for the references for the word and the colors).

 

circ4.PNG

I am really not sure how I should do to avoid the circular dependancy and still get the right results.

I look forward to hearing from you and thank you!!

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Alizee , if you trying to use measure in the column then it will give. Try the next one also as a measure

 

https://www.sqlbi.com/articles/avoiding-circular-dependency-errors-in-dax/

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

3 REPLIES 3
Icey
Community Support
Community Support

Hi @Alizee ,

 

How do you calculate "New Refs" and "KPI references" column? Could you create a sample .pbix file just with 'candidate' and 'candidate reference' table and related measures and columns for test? And please remove sensitive information.

 

Reference: How to provide sample data in the Power BI Forum - Microsoft Power BI Community

 

 

Best Regards,

Icey

amitchandak
Super User
Super User

@Alizee , if you trying to use measure in the column then it will give. Try the next one also as a measure

 

https://www.sqlbi.com/articles/avoiding-circular-dependency-errors-in-dax/

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thank you very much,

It worked eventually by having them as measures instead of calculated columns.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors