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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
pimo
Frequent Visitor

Sort non unique values by another column

Dear all,

I have a table of this kind:

 

ID    Name       FamilyID   SortingNumber

1      Robert           1                101

2      Mary             1                102

3      Paul              2                 60

4      Julia              2                 61

5      Robert          2                 59

 

I want to have these two slicers:

sorting.PNGBut I would like to have sorted Names (Robert on the top, since he has the lower SortingNumber).

 

If I do Sort by Column with sort [Name] By [SortingNumber] I get error: "We can't sort the Name column by SortingNumber. Ther can't be more than one value in SortingNumber for the same value in Name"

 

If I create a CalculatedColumn like: 

SortingNumber Unique = CALCULATE(MIN('Table'[SortingNumber]), ALLEXCEPT('Table','Table'[Name]))

I get an error too: "FailedName], [SortingNumber], [Name]".

Any advice?
I cannot create a new lookup table with all the Names becaused is not a pre-difined set of values....
6 REPLIES 6
parry2k
Super User
Super User

@pimo seems like you are trying to sort name column by Id and if that is the case it is not going to work because you have two different ids for same name, 1 and 5 for Robert, name and id has to be unique.

 

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop shop for Power BI related projects/training/consultancy.



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.

pimo
Frequent Visitor

Actually I'm trying to sort Name by SortingNumber (not by ID).

And yes, we goals is to get this ordered list of Name (by Sorting Number)


Name      Sorting Number
Robert              59
Paul                  60
Julia                  61
Rober              101
Mary                102


Yes, Robert is present two times but it is correct because they are two different persons with different IDs (but same names)

If i put this in slicer insted of table, I would like to see each member of a family sorted by its SortingNumber (not Alphabetically, nor by ID).

Is it possible?

@pimo it doesn't matter what column you are sorting by, logic remains the same, same name cannot have two different sort by column values. That's it. 

 

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop shop for Power BI related projects/training/consultancy.



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.

pimo
Frequent Visitor

Ok, but I was hoping thare was a trick...

 

For example sort (unique) ID by SortingNumber but "display" Name instead of ID.

 

@pimo Here's a trick I've found works (and for the benefit of anyone else ending up here with the same problem):

Add a new calculated column:

NameExtended = [Name] & REPT(" ",[Sorting Number])

Set the sort order of this column to your Sorting Number column and use it, rather than [Name], in your slicers.

The spaces added to the end of the name won't show in the slicer, but they effectively make each name instance unique.

Job done!

@pimo read more here 

 

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop shop for Power BI related projects/training/consultancy.



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.

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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