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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
o59393
Post Prodigy
Post Prodigy

Calculated columns not working due to circular dependency

Hi

 

I am doing two calculated columns and I am getting a circular dependency error in one of them.

 

The 'Capacity Real' column is basically a multiplication of =

 

[BPM Conversion Real] * [Mix by product] * Max hours column * CIP hours column 

 

And the 'Capacity Goal' columm multiples = 

 

[BPM Conversion Goal] * [Mix by product] *  Max hours column * CIP hours column 
 
o59393_0-1631473846235.png

 

 

How can I make it work? 

 

Pbix is attached below:
 

https://1drv.ms/u/s!ApgeWwGTKtFdh13Pj8JD18lE9HC8?e=3362I6

 

Regards.

1 ACCEPTED SOLUTION

This column expression avoids the error, but I definitely encourage you to fix your model.  Simple model, simple dax.

 

Capacity Goal =
VAR bpmgoal =
    CALCULATE (
        [BPM Conversion Goal],
        REMOVEFILTERS ( 'SKU by line - Official'[Capacity Real] )
    )
VAR mix =
    CALCULATE (
        [Mix by product],
        REMOVEFILTERS ( 'SKU by line - Official'[Capacity Real] )
    )
VAR result =
    IF (
        'SKU by line - Official'[Month] = 1,
        (
            bpmgoal * mix
                RELATED ( 'Hours by line - Official'[Max available time January (hours) [Calendar days - Non working days) * # of max shifts possible * hours per **bleep**] )
                RELATED ( 'Hours by line - Official'[Total hours to discount (CIP and Mold Changes) - January] )
        ) * 60,
        IF (
            'SKU by line - Official'[Month] = 2,
            (
                bpmgoal * mix
                    RELATED ( 'Hours by line - Official'[Max available time February (hours) [Calendar days - Non working days) * # of max shifts possible * hours per **bleep**] )
                    RELATED ( 'Hours by line - Official'[Total hours to discount (CIP and Mold Changes) - February] )
            ) * 60,
            0
        )
    )
RETURN
    result

 

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

10 REPLIES 10
mahoneypat
Microsoft Employee
Microsoft Employee

I looked at your file, and commented out parts of your expression to see which is causing the dependency error.  Both the measures part and the LOOKUPVALUE parts cause it.  Looking at your columns, you have multiple pivoted columns that have similar data in them (e.g., Jan and Feb data).  You really should improve your model (unpivot and set up 1:M relationships with single direction filters).  Having a simpler model leads to simpler DAX.

 

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Hi @mahoneypat 

 

Correct I have multiple pivoted columns in 'Hours by line' table. From January to December. I remain it that way because it allows me to keep the column 'Plant-Line-Package' with unique values and make the bridge between tables.

 

I did change my relationship from 1:M :

 

o59393_0-1631476167641.png

 

I tried using the calculate underneath the IF statement but still shows red:

 

o59393_1-1631476288254.png

 

 

Can you further advise? 

 

Thanks!

 

 

 

Hi @mahoneypat 

 

Can you please further advise once I change to 1:M ?

 

How can I make this circular dependency error work.


Thanks. 

I looked at it some more, but this model needs to much work.  I could avoid the circ error by using REMOVEFILTERS with the two measures, but it the LOOKUPVALUES in multiple calculated columns is also causing a circ error.  You should improve your model and/or consider using RELATED to get a value from the other table instead of LOOKUPVALUE.

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Hi @mahoneypat 

 

I changed it to RELATED. Please have a look to the pbix.

 

Regards,

This column expression avoids the error, but I definitely encourage you to fix your model.  Simple model, simple dax.

 

Capacity Goal =
VAR bpmgoal =
    CALCULATE (
        [BPM Conversion Goal],
        REMOVEFILTERS ( 'SKU by line - Official'[Capacity Real] )
    )
VAR mix =
    CALCULATE (
        [Mix by product],
        REMOVEFILTERS ( 'SKU by line - Official'[Capacity Real] )
    )
VAR result =
    IF (
        'SKU by line - Official'[Month] = 1,
        (
            bpmgoal * mix
                RELATED ( 'Hours by line - Official'[Max available time January (hours) [Calendar days - Non working days) * # of max shifts possible * hours per **bleep**] )
                RELATED ( 'Hours by line - Official'[Total hours to discount (CIP and Mold Changes) - January] )
        ) * 60,
        IF (
            'SKU by line - Official'[Month] = 2,
            (
                bpmgoal * mix
                    RELATED ( 'Hours by line - Official'[Max available time February (hours) [Calendar days - Non working days) * # of max shifts possible * hours per **bleep**] )
                    RELATED ( 'Hours by line - Official'[Total hours to discount (CIP and Mold Changes) - February] )
            ) * 60,
            0
        )
    )
RETURN
    result

 

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Awesome @mahoneypat it worked!!

 

I tried your advise to make the model simpler. So I unpivoted the columns:

 

o59393_0-1631583389976.png

 

Did a M:M relationship cause it was the only way to bridge the tables:

 

o59393_1-1631585496641.png

 

And then I updated the code with filter:

 

Capacity Real = 

IF (
'SKU by line - Official'[Month] = 1,
(
[BPM Conversion Real] * [Mix by product]
* 
FILTER(
    'Hours by line - Official',
RELATED( 
    'Hours by line - Official'[Attribute]) = "Hours by line - Official'[Max available time January (hours) [Calendar days - Non working days) * # of max shifts possible * hours per **bleep**]"
)
* 
FILTER(
    'Hours by line - Official',
RELATED( 
    'Hours by line - Official'[Attribute]) = "Hours by line - Official'[Total hours to discount (CIP and Mold Changes) - January]"
)
) * 60,
IF (
'SKU by line - Official'[Month] = 2,
(
[BPM Conversion Real] * [Mix by product]
* 
FILTER(
    'Hours by line - Official',
RELATED( 
    'Hours by line - Official'[Attribute]) = "Hours by line - Official'[Max available time February (hours) [Calendar days - Non working days) * # of max shifts possible * hours per **bleep**]"
)
* 
FILTER(
    'Hours by line - Official',
RELATED( 
    'Hours by line - Official'[Attribute]) = "Hours by line - Official'[Total hours to discount (CIP and Mold Changes) - February]"
)
) * 60,
0
)
)

 

I got the following error:

 

The column 'Hours by line - Official[Attribute]' either doesn't exist or doesn't have a relationship to any table available in the current context.

 

In case you wanna have a look at the pbix with the unpivoted columns.

 

You still solved my original problem and I really appreciate your help!

 

 

 

 

 

Hi @mahoneypat 

 

Ok let me try to use RELATED instead and come back to you.

 

Thanks.

mahoneypat
Microsoft Employee
Microsoft Employee

Please see how to remove filters from your dependent column(s) in this article/video.

Avoiding circular dependency errors in DAX - SQLBI

 

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Hi @mahoneypat 


From what I've seen I have to use Calculate and AllExcept, as soon as I use calculate my column goes like this:

 

o59393_0-1631474632995.png

 

I am not sure what should I exclude with all AllExcept.

 

The capacity column is calculated with 2 measures and 2 columns from the other table.

 

Thanks.

 

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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