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

July 28 - August 9 | Final Round of the Power BI Dataviz World Championships. This is your chance. Learn more

Reply
karthik77700
Helper I
Helper I

circular dependency error while sorting multiple records

I have an requirement to sort country wise currently data available :

Country      Limits           Type       

US                 20USD       Insure

US                 30 USD      Secure

Canada          40 USD      Pecure

Vietnam         80 USD      Lecture

I have created calculated column and sort based on condition Canada=1,US=2,Vietnam=3

When i try to sort country column based on calculated column getting circular depedndency error since we have multiple values for US .

Output Expected in tables:

Country      Limits           Type       

Canada          40 USD      Pecure

US                 20USD       Insure

US                 30 USD      Secure
Vietnam         80 USD      Lecture

Any helps appreciated!

1 ACCEPTED SOLUTION
mark_endicott
Super User
Super User

@karthik77700 - Apply the logic in Power Query through adding a "Custom Column":

 

mark_endicott_0-1750258326473.png

 

This will load the data into the table already, and mean there is no circular dependency on the original column. 

 

If I answered your question please mark my post as the solution, it helps others with the same challenge find the answer!

View solution in original post

2 REPLIES 2
mark_endicott
Super User
Super User

@karthik77700 - Apply the logic in Power Query through adding a "Custom Column":

 

mark_endicott_0-1750258326473.png

 

This will load the data into the table already, and mean there is no circular dependency on the original column. 

 

If I answered your question please mark my post as the solution, it helps others with the same challenge find the answer!

wardy912
Super User
Super User

You're encountering a circular dependency error because you're trying to sort the Country column using a calculated column that depends on Country itself, which Power BI doesn't allow when the relationship isn't one-to-one (multiple rows for "US").

 

To avoid this, you can create a separate table that defines the custom sort order and then use it to sort your main table.

 

1. Create a Sort Table

 

Go to Modeling > New Table and enter:


CountrySortOrder = DATATABLE(
    "Country", STRING,
    "SortOrder", INTEGER,
    {
        {"Canada", 1},
        {"US", 2},
        {"Vietnam", 3}
    }
)


2. Create a Relationship

 

Go to Model view.
Create a relationship between YourMainTable[Country] and CountrySortOrder[Country].

 

3. Sort the Country Column

 

In your main table, select the Country column.
Click "Sort by Column" and choose CountrySortOrder[SortOrder].

 

This will allow Power BI to sort the Country column without circular dependency, even if there are multiple rows per country.

 

Please give a thumbs up if this fixes your issue.

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

Fabric Community Sticker Design Challenge Barcelona Carousel

Fabric Community Sticker Challenge - Barcelona 2026

If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!

July Power BI Update Carousel

Power BI Monthly Update - July 2026

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

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors