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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Learner22
Helper I
Helper I

Circular dependency when sorting a column by another column

Dear Community,

 

I have a calculated column like this

 

interval

0-5

11-20

6-10

21-30

>30

 

I want to have the column interval like this

 

interval

0-5

6-10

11-20

21-30

>30

I use this column in a matirx, but I get the wrong order. I would like to have the cloumn in a matrix in this way

0-5   6-10  11-20  21-30  >31

 

I have created a second column (let's call this index) like if the interval is = 0-5 then 1, if interval = 6-10 then 2 etc. If I order the interval column by the idex column, I get the error cylic dependency.

 

How can I solve this problem?

 

Thank you very much for your help.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @Learner22 ,

I created some data:

vyangliumsft_0-1671087353537.png

Here are the steps you can follow:

1. In Power query. Add Column – Index Column – From 1.

vyangliumsft_1-1671087353542.png

2. Create calculated table.

Table 2 =
SUMMARIZE('Table','Table'[interval],"Index",MINX(FILTER(ALL('Table'),'Table'[interval]=EARLIER('Table'[interval])),[Index]))

vyangliumsft_2-1671087353544.png

3. [interval] – Sort by column – [index].

vyangliumsft_3-1671087353546.png

4. Connect two relations with [interval].

vyangliumsft_4-1671087353547.png

5. Result:

vyangliumsft_5-1671087353551.png

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

View solution in original post

7 REPLIES 7
Anonymous
Not applicable

Hi  @Learner22 ,

I created some data:

vyangliumsft_0-1671087353537.png

Here are the steps you can follow:

1. In Power query. Add Column – Index Column – From 1.

vyangliumsft_1-1671087353542.png

2. Create calculated table.

Table 2 =
SUMMARIZE('Table','Table'[interval],"Index",MINX(FILTER(ALL('Table'),'Table'[interval]=EARLIER('Table'[interval])),[Index]))

vyangliumsft_2-1671087353544.png

3. [interval] – Sort by column – [index].

vyangliumsft_3-1671087353546.png

4. Connect two relations with [interval].

vyangliumsft_4-1671087353547.png

5. Result:

vyangliumsft_5-1671087353551.png

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Hi @Anonymous ,

 

thank you very much for your help. There ist just one problem regarding your solution. I want to have the following created table

 

Interval     index

0-5              1

6-10            2

11-20          3

21-30          4

>30             5

 

For example, in your case, the interval 11-20 (and not 6-10) has the index number 2.

How can I assign the correct index number to the intervals?

 

Many thanks!

 

I was able to solve the problem. Thank you again for your help.

tamerj1
Super User
Super User

Hi @Learner22 

use the same dax code you used to created the column [interval] only replace the interval with integer number. For example replace "0-5" with 1 and "6-10" with 2 and so on. Then use the new column to sort by. 

LPBI
Frequent Visitor

Landed here with the same issue, I prefer your solution rather than create another table 👏

Hi @tamerj1 ,

 

Thank you for your reply. I want to keep the interval column, because the entries in the interval column refer to the days. Unfortunately, replacing "0-5" with 1 and so on doesn't help me.

@Learner22 

Of course you will keep it. Just create a new column

Helpful resources

Announcements
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 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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