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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply

Circular Dependency when using variable in measures

Hi there,

 

Currently, I'm trying to get two different measures to show as follows and am getting an error on the second variable.

BuildingYearValueType CostTypeValue ThousandsGroup TOTAL A  TOTAL B Multiplier
A2021123Amort YearRecoverable500B                    5,000.00                   6,000.001.5
A2021123Add YearRecoverable100A                    5,000.00                   6,000.001.3
A2022124Add YearRecoverable30B                    5,000.00                   6,000.001.69
A2023125Add YearNon-Recoverable200B                    5,000.00                   6,000.001.4
A2024126Add YearNon-Recoverable0B                    5,000.00                   6,000.001.5
A2025127Add YearNon-Recoverable0B                    5,000.00                   6,000.001.8
B2021123Add YearRecoverable500A                    3,000.00                   4,000.001.3
B2022124Add YearRecoverable100B                    3,000.00                   4,000.001.69
B2023124Add YearNon-Recoverable30B                    3,000.00                   4,000.001.4
B2024124Add YearNon-Recoverable200B                    3,000.00                   4,000.001.5
B2025125Add YearNon-Recoverable0B                    3,000.00                   4,000.001.8
B2021125Amort YearNon-Recoverable0B                    3,000.00                   4,000.001

 

 

The calculation I'm using is as follows. The following returns a 0

% of TOTAL A
VAR ANUMERATOR =
DIVIDE(
    CALCULATE(
    SUM('Data'[Value]),
    'Data'[Group]<>"A" &&
    'Data'[Type Cost]="Add Year"),
    1000)
    VAR ADENOMINATOR =
    DIVIDE(
    (SUM(Data'[Multiplier])*SUM('Data'[TOTAL A])),
    1000)
    RETURN ANUMERATOR/ADENOMINATOR

 

% of TOTAL B
VAR BNUMERATOR =
DIVIDE(
    CALCULATE(
    SUM('Data'[Value]),
    'Data'[Group]<>"A" &&
    'Data'[Type Cost]="Add Year"&&
     'Data'[Type]="Non-Recoverable"),
    1000)
    VAR BDENOMINATOR =
    DIVIDE(
    (SUM(Data'[Multiplier])*SUM('Data'[TOTAL B])),
    1000)
    RETURN BNUMERATOR/BDENOMINATOR

 

Just wondering if anyone has any better formulas that can be used? When I split out the denominators and numerators, I kept getting errors.

 

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

You have a couple of typos in your formulas, but there is no circular dependency anywhere.

 

 

% of TOTAL A = 
VAR ANUMERATOR =
    DIVIDE (
        CALCULATE (
            SUM ( 'Data'[Value] ),
            'Data'[Group] <> "A",
            'Data'[Type Cost] = "Add Year"
        ),
        1000
    )
VAR ADENOMINATOR =
    DIVIDE ( SUM ( 'Data'[Multiplier] ) * SUM ( Data[ TOTAL A ] ), 1000 )
RETURN
    DIVIDE ( ANUMERATOR, ADENOMINATOR )

% of TOTAL B =
VAR BNUMERATOR =
    DIVIDE (
        CALCULATE (
            SUM ( 'Data'[Value] ),
            'Data'[Group] <> "A",
            'Data'[Type Cost] = "Add Year",
            'Data'[Type] = "Non-Recoverable"
        ),
        1000
    )
VAR BDENOMINATOR =
    DIVIDE ( ( SUM ( 'Data'[Multiplier] ) * SUM ( 'Data'[ TOTAL B ] ) ), 1000 )
RETURN
    DIVIDE ( BNUMERATOR, BDENOMINATOR )

 

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi, @analyticspbi87 

Do you have to use calculated columns, please? Can you use Measure?


Can you share the results you expect to get and the logic behind the calculation?

 

We will do our best to help you solve the problem you are having.

 

 

I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.
Best Regards,
Fen Ling,
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

lbendlin
Super User
Super User

You have a couple of typos in your formulas, but there is no circular dependency anywhere.

 

 

% of TOTAL A = 
VAR ANUMERATOR =
    DIVIDE (
        CALCULATE (
            SUM ( 'Data'[Value] ),
            'Data'[Group] <> "A",
            'Data'[Type Cost] = "Add Year"
        ),
        1000
    )
VAR ADENOMINATOR =
    DIVIDE ( SUM ( 'Data'[Multiplier] ) * SUM ( Data[ TOTAL A ] ), 1000 )
RETURN
    DIVIDE ( ANUMERATOR, ADENOMINATOR )

% of TOTAL B =
VAR BNUMERATOR =
    DIVIDE (
        CALCULATE (
            SUM ( 'Data'[Value] ),
            'Data'[Group] <> "A",
            'Data'[Type Cost] = "Add Year",
            'Data'[Type] = "Non-Recoverable"
        ),
        1000
    )
VAR BDENOMINATOR =
    DIVIDE ( ( SUM ( 'Data'[Multiplier] ) * SUM ( 'Data'[ TOTAL B ] ) ), 1000 )
RETURN
    DIVIDE ( BNUMERATOR, BDENOMINATOR )

 

I have revised the dataset to a more similar structure and tried to make the formula in a new PBIX file and still getting circular reference errors.

 

I have attached them in the following link 

https://www.dropbox.com/scl/fo/fztltp5tdoipz3lugw5gk/ANKot9kvrP5XcN4SwFpb91s?rlkey=svodmouimp1lrlaxq... 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.