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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

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
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors