Forum Discussion

pimo's avatar
pimo
Frequent Visitor
6 years ago

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:

But 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

  • 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.

    • pimo's avatar
      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?

      • parry2k's avatar
        parry2k
        Super User

        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.