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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
marcel97
Helper II
Helper II

Circular dependency when working with primary keys

Hello all,

 

I am currently trying to remove a circular dependency in Power BI and could not find any solution when doing some research.

 

I am managing a dashboard for our project management office. Recently we got access to a data base with time booking data. Find attached the simplified data:

 

I have one team table, in which I have a team hierarchy:

 

TEAM_ORDERTEAM_IDTEAM_PARENT_IDIDENTIFIER
A1 A
D21AD
W32ADW
B42ADB
S53ADWS
N63ADWN
Y74ADBY

 

The time bookings I source look as follows:

 

DEPARTMENT_NAMEHOURS_BOOKINGPERIOD
ADWS502022/02
ADWN402022/02
ADBY702022/02

 

I have added new columns to the team table in Power BI:

 

TEAM_ORDERTEAM_IDTEAM_PARENT_IDIDENTIFIERPATHL1L2L3L4
A1 A1A   
D21AD1|2AAD  
W32ADW1|2|3AADADW 
B42ADB1|2|4AADADB 
S53ADWS1|2|3|5AADADWADWS
N63ADWN1|2|3|6AADADWADWN
Y74ADBY1|2|4|7AADADBADBY

 

For PATH I have used the PATH function and for L1-L4 I have used a LOOKUPVALUE function, that returns TEAM_ORDER for the 1st, 2nd... respective PATH_ITEM {e.g. L1 =

LOOKUPVALUE(Team[TEAM_ORDER], Team[TEAM_ID], VALUE(PATHITEM(Team[PATH],1))) }
 
In the time bookings table I have added a column where I source the TEAM_ID:
DEPARTMENT_NAMEHOURS_BOOKINGPERIODTEAM_ID
ADWS5001. Feb 225
ADWN4001. Feb 226
ADBY7001. Feb 227
 
TEAM_ID = CALCULATE(FIRSTNONBLANK(Team[TEAM_ID],1), FILTER(ALL(Team), Bookings[DEPARTMENT_NAME]=Team[IDENTIFIER]))
 
Now when I try to create a relationship between the TEAM_ID columns I get the following error message that a circular dependency was created:
marcel97_0-1643705565514.png

 

 

I know that it must originate from the L1-L4 calculations as I did not experience this issue without them, however, I need these columns for further processing.

 

Any way to work around this?

 

Any help is appreciated!

 

Thanks and kind regards

Marcel

1 ACCEPTED SOLUTION
ValtteriN
Super User
Super User

Hi,

I recommend cheking this article by SQLBI. They cover the reasons for these kinds of errors quite well: https://www.sqlbi.com/articles/avoiding-circular-dependency-errors-in-dax/





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

2 REPLIES 2
ValtteriN
Super User
Super User

Hi,

I recommend cheking this article by SQLBI. They cover the reasons for these kinds of errors quite well: https://www.sqlbi.com/articles/avoiding-circular-dependency-errors-in-dax/





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Hey @ValtteriN !

 

At first I thought the solutions provided in this articel did not help - turns out I had a syntax error in one of my columns.

 

Thanks a lot! Replacing ALL with ALLNOBLANKROW within the CALCULATE function did help indeed.

 

Kind regards

Marcel

Helpful resources

Announcements
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

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