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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
PetyrBaelish
Resolver III
Resolver III

Sorting problem

I have a visualisation which is a league table.

 

The columns in view include Player, Points, Wins, 2nd, 3rd etc.

 

In the event that Points are tied I have created a calculated column in my table called "PointsForSorting" which is essentially Points + (Wins*0.0001)+(2nd*0.0000001) etc.

 

The PointsForSorting column is more accurate for sorting purposes as the points column will divide those tied on points alphabetically which is incorrect in this case.

 

I'm trying to follow the advice via the link below, but it's not working. I select the PointsForScoring field in my fields pane, select my visual, select the modelling tab -> Sort by column, select PointsForScoring but the visual doesn't update. In fact whatever I select under "Sort By Column" doesn't affect the visual.

 

Could decimilisation be the issue? I've noticed if I drag the PointsForScoring column onto the visual it is set at 2dp (which isn't sufficient)

 

https://docs.microsoft.com/en-us/power-bi/desktop-sort-by-column

 

1 ACCEPTED SOLUTION

Thanks for your help. I couldn't do this in Power Query as my Results table contained the following data:

 

Tournament - Player - Result

22/12/2018 - Danny - 1st

22/12/2018 - Janet - 2nd

 

I had another table called Points as follows:

 

Result - Points

1st - 16

2nd - 12

 

The Points Measure was modelled with the formula:

Points = RELATED('Points'[Points])

 

I attempted In Power Query Editor to include a custom column with an IF statement (If Results = 1st, 16, If Result = 2nd, 12 ...) but it complained that the term "IF" was unrecognized.

 

In the end I decided there was no need for a separate Points and PointsForSorting columns, and recreated the Points column as follows:

Points = RELATED('Points'[Points])+(Results[1st]*0.0001)+(Results[2nd]*0.0000001)+(Results[3rd]*0.0000000001)

 

This seems to have worked.

View solution in original post

4 REPLIES 4
jthomson
Solution Sage
Solution Sage

You need to select the points column and have that sorted by pointsforscoring

Unfortunately that's not working for me. I select the Points column from the fields list, select my visualisation, then modelling tab -> sort by column, select the PointsForSorting column but I receive the error message "This column can't be sorted by a column that is already sorted, directly or indirectly, by this column"

 

I checked the PointsForSorting column (selected it in the fields pane, selected my visualisation -> sort by column) and the PointsForSorting column is sorted by itself (as the default).

 

I'm assuming the error message is referencing the fact that the PointsForSorting calculated column uses the Points column in its formula (which it has to), so I'm not sure what else I can do??

@PetyrBaelish you are right, pointforsorting is referring to point column and that's why it is not allow to sort. you can create this "pointforsorting" column in power query instead using dax.

 

although I'm mot sure it will stil work because you have tied point and try to sort the tied point with non-tied sort column , and it will give error (i think so)

 

for example , if you have following tied points

 

Point PointSorted

1       1.01

1       1.02

1       1.03

 

and if you try to sort point by pointsorted, it will give error message.

 

I think first and foremost is to create "pointsorted" in power query and go from there.

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Thanks for your help. I couldn't do this in Power Query as my Results table contained the following data:

 

Tournament - Player - Result

22/12/2018 - Danny - 1st

22/12/2018 - Janet - 2nd

 

I had another table called Points as follows:

 

Result - Points

1st - 16

2nd - 12

 

The Points Measure was modelled with the formula:

Points = RELATED('Points'[Points])

 

I attempted In Power Query Editor to include a custom column with an IF statement (If Results = 1st, 16, If Result = 2nd, 12 ...) but it complained that the term "IF" was unrecognized.

 

In the end I decided there was no need for a separate Points and PointsForSorting columns, and recreated the Points column as follows:

Points = RELATED('Points'[Points])+(Results[1st]*0.0001)+(Results[2nd]*0.0000001)+(Results[3rd]*0.0000000001)

 

This seems to have worked.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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