How to Fix "A Circular Dependency Was Detected" in Power BI

Fix A circular dependency was detected error in Power BI

You write a new calculated column or calculated table in Power BI, press Enter, and get a red error: "A circular dependency was detected". The formula looks correct, it may even have worked a minute ago, and now nothing works.

This error means two (or more) objects in your model depend on each other, so Power BI does not know which one to calculate first. In this guide you will learn the 5 most common causes and the exact fix for each one.

Quick answer: Read the error message: it lists the objects in the loop, for example Sales[Bonus], Sales[Rank], Sales[Bonus]. The usual causes are (1) two calculated columns using CALCULATE in the same table, (2) a calculated table built with VALUES or ALL and then joined to the source table, or (3) two measures or columns that refer to each other. Fix them with ALLEXCEPT/REMOVEFILTERS, by using DISTINCT instead of VALUES, or by moving the logic into a measure or Power Query.

What "circular dependency" means

Power BI calculates calculated columns and calculated tables in order, during refresh. If A needs B, then B must be calculated first. If B also needs A, there is no valid order:

ObjectDepends on
Column AColumn B
Column BColumn A ❌ (loop)

Sometimes the loop is obvious. More often it is hidden, because some DAX functions create dependencies you cannot see in the formula. Those hidden cases are the ones that confuse most people.

Cause 1: Two calculated columns that refer to each other

This is the simple case:

Sales[Net]   = Sales[Amount] - Sales[Discount]
Sales[Discount] = Sales[Net] * 0.05

Net needs Discount, Discount needs Net. The same thing happens with measures: if [Profit] uses [Margin %] and [Margin %] uses [Profit], Power BI shows the same error.

Fix: break the loop by calculating one value from the raw columns only. For example: Sales[Discount] = Sales[Amount] * 0.05, then Sales[Net] = Sales[Amount] - Sales[Discount]. Draw the chain on paper if needed: every chain must end at a raw column.

Cause 2: Two calculated columns with CALCULATE in the same table (most common)

This one surprises almost everyone. Say you add a column with the total sales of each customer:

Customer[Total Sales] =
CALCULATE ( SUM ( Sales[Amount] ) )

It works. Then you add a second, similar column:

Customer[Total Orders] =
CALCULATE ( COUNTROWS ( Sales ) )

And suddenly: circular dependency detected. Neither formula mentions the other column, so why?

Why it happens

Inside a calculated column, CALCULATE turns the current row into a filter. This is called context transition. To do that, it filters on every column of the row, including the other calculated columns. So Total Sales depends on all columns of the Customer table, including Total Orders, and Total Orders depends on all columns, including Total Sales. That is a loop.

You see this most often in tables without a unique key column, such as a fact table or a table you built yourself. When the table is on the "one" side of a relationship, Power BI knows its key is unique and can often avoid the problem, but the fix below works in every case.

The fix: filter only by the key column

Tell CALCULATE to keep only the key column filter and ignore the rest:

Customer[Total Sales] =
CALCULATE (
    SUM ( Sales[Amount] ),
    ALLEXCEPT ( Customer, Customer[CustomerID] )
)

Customer[Total Orders] =
CALCULATE (
    COUNTROWS ( Sales ),
    ALLEXCEPT ( Customer, Customer[CustomerID] )
)

Now each column depends only on CustomerID, and the loop is gone. You can also write REMOVEFILTERS ( Customer[Total Orders] ) to ignore one specific column, but ALLEXCEPT on the key is easier to maintain when you add more columns later.

Even better: ask yourself whether this should be a column at all. A measure like Total Sales = SUM ( Sales[Amount] ) placed in a visual next to Customer gives the same number, respects slicers, and never causes this error. See Calculated Columns vs Measures.

Cause 3: A calculated table made with VALUES or ALL, then related to the source

A popular shortcut is to build a dimension table from the fact table:

Products = VALUES ( Sales[Product] )

Then you create a relationship from Products[Product] to Sales[Product] and get a circular dependency.

Why it happens

VALUES and ALL can return an extra blank row, which Power BI adds when a relationship has values on the many side that are missing on the one side. So the calculated table depends on the relationship, and the relationship depends on the calculated table: a loop.

The fix: use DISTINCT

Products = DISTINCT ( Sales[Product] )

DISTINCT never adds the blank row, so it does not depend on relationships. The same rule applies to ALL ( Sales[Product] ) and to SUMMARIZE-based tables: switch to DISTINCT or ALLNOBLANKROW.

Best practice: build dimension tables in Power Query (Reference the query → Remove other columns → Remove duplicates) instead of DAX. They load faster and never create dependency loops.

Cause 4: A calculated column that uses RELATED across a calculated table

Example: you created Products = DISTINCT ( Sales[Product] ), then added a column in Products that sums Sales, and then a column in Sales that uses RELATED ( Products[Category Total] ). Now Sales depends on Products, and Products (built from Sales) depends on Sales.

Fix: keep one direction only. Either calculate the total as a measure, or create the dimension table in Power Query from the source data, not from the DAX table that uses it.

Cause 5: Date tables built from the fact table

A common version of Cause 3:

Date = CALENDAR ( MIN ( Sales[OrderDate] ), MAX ( Sales[OrderDate] ) )

Then a calculated column in Sales uses the Date table (for example a fiscal year via RELATED), or the Date table has columns that use CALCULATE over Sales. The loop appears as soon as both sides depend on each other.

Fix: use fixed dates, or CALENDARAUTO(), or build the date table in Power Query. For example:

Date = CALENDAR ( DATE ( 2023, 1, 1 ), DATE ( 2026, 12, 31 ) )

How to find the loop quickly

  1. Read the full error. Power BI lists the chain, for example Customer[Total Sales], Customer[Total Orders], Customer[Total Sales]. The objects in that list are the loop.
  2. Think about what changed last. The error appears on the object you just created, but the cause is often an older column.
  3. Look for CALCULATE in calculated columns and for VALUES, ALL or CALENDAR(MIN(...)) in calculated tables.
  4. Temporarily delete or comment out one formula in the chain (replace it with = 0) and see if the error goes away.
  5. Move logic out of DAX columns: measures for aggregations, Power Query for row-level transformations and dimension tables.

Similar errors that are different

  • "A cyclic reference was encountered during evaluation" is a Power Query error. Query A references Query B and B references A. Fix it in Power Query by using Reference in one direction only.
  • "You can't create a direct active relationship… because an active set of relationships already exists" is an ambiguous relationship path, not a circular dependency. Make one of the relationships inactive and use USERELATIONSHIP in a measure. Read One-to-Many vs Many-to-Many relationships.

Frequently asked questions

What does "a circular dependency was detected" mean in Power BI?

It means two or more columns, tables, measures or relationships depend on each other, so Power BI cannot decide which one to calculate first.

Why do I get a circular dependency when the columns do not refer to each other?

Because CALCULATE in a calculated column filters on every column of the current row (context transition), including your other calculated columns. Use ALLEXCEPT ( Table, Table[Key] ) inside CALCULATE to remove that hidden dependency.

Should I use VALUES or DISTINCT for a calculated table?

Use DISTINCT when the new table will be related to the table it came from. VALUES can include a blank row that depends on relationships and causes a loop.

Can measures cause a circular dependency?

Only if two measures refer to each other directly or through a chain. Measures never depend on calculated columns in a hidden way, which is one more reason to prefer measures for aggregations.

Does a circular dependency break my whole report?

The object with the error cannot be calculated, and visuals using it show an error. Other parts of the report keep working. Fix the loop and refresh.

Keep learning

Most circular dependency errors come from calculated columns doing the work of measures. To understand row context, filter context and context transition step by step, follow the Free Power BI Course (138 lessons). Start with Understanding CALCULATE in DAX and ALL and ALLEXCEPT in DAX, and keep the Power BI DAX Cheat Sheet close.

Still stuck? Paste the full error message and your formula in the comments, and I will help you find the loop.

Tags

Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.
Learn Excel, Power BI, and Finance in Simple Hindi and English Follow step-by-step tutorials and practical examples designed for students, job seekers, and working professionals. We cover Power BI dashboards, DAX formulas, Excel tricks, financial literacy, and AI tools.