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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
PVO3
Impactful Individual
Impactful Individual

Relationship circular dependency calculated column

Hello data friends,

 

I'm having an issue that I can't fix. I'm trying to create a relationship between a fact and a dim table, but I receive a circular dependency error. Read a lot of post and documentation, but I still can't figure it out.

 

Example file 

 

The issue is a calculated column which has to act as a foreign key in the dim table. This column removes duplicate values by using only the ID of the highest Index, so I should be able to create a one-to-many relationship.

It works perfect if I create a DAX reference table (so the calculated column is just a reference).

 

FK = 
VAR _index = Dim[Index]
VAR _id =
CALCULATE(
    COUNTROWS(Dim),
    FILTER(
        ALLEXCEPT(Dim,Dim[ID]),
        Dim[Index] > _index
    )
)
RETURN

IF( 
    ISBLANK( _id ) && NOT ISBLANK(Dim[ID]), 
    Dim[ID], 
    Dim[ID] & "-" & Dim[Index]
)

 

But when trying to create a relationship between both tables I get a circular dependency error. Even when removing all other calculated columns. I can't find the depencency. My fact table has no reference whatsoever, the only DAX code I'm using is the code above. 

 

Hope one of you is able to help me! Thanks a lot.

 

 

 

 

 

 

 

 

2 ACCEPTED SOLUTIONS
Jihwan_Kim
Super User
Super User

Hi,

Please try to create [FK] calculated column by using the below DAX formula.

And then create a relationship.

 

FK =
VAR _index = Dim[Index]
VAR _id =
    CALCULATE (
        COUNTROWS ( Dim ),
        FILTER ( Dim, Dim[ID] = EARLIER ( Dim[ID] ) && Dim[Index] > _index )
    )
RETURN
    IF (
        ISBLANK ( _id ) && NOT ISBLANK ( Dim[ID] ),
        Dim[ID],
        Dim[ID] & "-" & Dim[Index]
    )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

PVO3
Impactful Individual
Impactful Individual

@Jihwan_Kim thanks a lot! Such an easy solution. I even had the solution in front of me the entire time. Just should have used the same technique as with the index... Ps. I swapped the your EARLIER for a variable.

 

VAR _var = dim[id]

FILTER(dim, 

    dim[id] = _var)

 

 

 

View solution in original post

2 REPLIES 2
Jihwan_Kim
Super User
Super User

Hi,

Please try to create [FK] calculated column by using the below DAX formula.

And then create a relationship.

 

FK =
VAR _index = Dim[Index]
VAR _id =
    CALCULATE (
        COUNTROWS ( Dim ),
        FILTER ( Dim, Dim[ID] = EARLIER ( Dim[ID] ) && Dim[Index] > _index )
    )
RETURN
    IF (
        ISBLANK ( _id ) && NOT ISBLANK ( Dim[ID] ),
        Dim[ID],
        Dim[ID] & "-" & Dim[Index]
    )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
PVO3
Impactful Individual
Impactful Individual

@Jihwan_Kim thanks a lot! Such an easy solution. I even had the solution in front of me the entire time. Just should have used the same technique as with the index... Ps. I swapped the your EARLIER for a variable.

 

VAR _var = dim[id]

FILTER(dim, 

    dim[id] = _var)

 

 

 

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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
Top Kudoed Authors