Forum Discussion
Sort by another column
Hello
can please someone advise what I'm doing wrong here
my table has no duplicates
i am trying to sort the stage column by rank column
Maz_0102 , [Stage] is blank for all four, but each has a different Rank (1, 2, 3, 4). So the single Stage value blank maps to four different Rank values → Power BI refuses, because it wouldn't know which rank to sort blank by.
Option 1: If Category is unique so instead of Stage, use the Category column
Option 2: Merge Category and Stage and then apply sort
3 Replies
- Tahreem24Super User
Maz_0102 , [Stage] is blank for all four, but each has a different Rank (1, 2, 3, 4). So the single Stage value blank maps to four different Rank values → Power BI refuses, because it wouldn't know which rank to sort blank by.
Option 1: If Category is unique so instead of Stage, use the Category column
Option 2: Merge Category and Stage and then apply sort - MFelixSuper User
Hi Maz_0102 ,
The problem is on the rnak 1 to 4. The first question is that when you have blank values you cannot sort the column because the blanks are not recognize, in second place since you have the same value (in this case blank) with different rank that cannot also be done you need to have distinct values for each value in the stage column.
What you can do has a workaround is to paste an empty carachter for each of the ID were you want to have blanks basically repeat the empty character the number of times of your ID then you should be abble to do the sorting.
You would have the following
1 - EmptyChar
2 - EmptyCharEmptyChar
3 - EmptyCharEmptyCharEmptyChar
4 - EmptyCharEmptyCharEmptyCharEmptyChar
This would should has blank but in reality you will have some characters there.
Copy the empty character from the link below.
- MohamedFowzan1Super User
Hi Maz_0102
If the same Stage value is associated with different Rank values, Power BI won't let you use Sort by Column because each Stage must map to one unique Rank.
If the only inconsistency is for blank stages, you could create a new rank column like this:
Sort Rank = IF( ISBLANK('Table'[Stage]), 10000, 'Table'[Rank] )One thing to be aware of is that this can sometimes lead to a circular dependency, which is a known issue in certain scenarios.
If that happens, a better approach is to create a separate lookup table (e.g., in Power Query) that contains one row per Stage with its corresponding Rank, then relate or merge it back into your model. This ensures each Stage has a unique Rank and avoids the circular dependency.
and finally the easiest fix would be if you could get the correct stage names populated not having any blank, the above can be used if the blanks are needed to be there