Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
1 year ago

How do I sort a matrix based on a column

Hello, I am trying to replicate this Tableau table in PowerBI: 

I'm almost there, but I'm struggling to get that ascending sort, broken down by 2021, working.

 

I've already tried to 'sort by column' using Year, but I receive the error: 

 

So I'm out of ideas, can anyone help?

 

5 Replies

  • Anonymous 

    you can check in the data, if there two columns are one to one relationship. If one value in the column has different corresponding values. Then you can not do the sort by and will get the error message.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi, looks like you're right. How could I resolve this?

       

      It's worth me mentioning that 'application year string' can hold strings like '2020a'.

      • ryan_mayu's avatar
        ryan_mayu
        Super User

        then you have to clean the data and change 2020a to 2020.

        Maybe you can provide some sample data, let's see how we can clean your data automatically.

  • Hello Anonymous,

     

    Add Column as year in your PowerQuery as number format. Close & Apply.

    And select your one required column and sort by column that you added column on power query side.

    İf you added a column on dax(new column) that doesn't make sort by columns(Not all columns but some referance columns)

     

    Kind Regards,
    Gökberk Uzuntaş

    📌 If this post helps, then please consider Accepting it as a solution and giving Kudos — it helps other members find answers faster!

    🔗 Stay Connected:
    📘 Medium |
    📺 YouTube |
    💼 LinkedIn |
    📷 Instagram |
    🐦 X |
    👽 Reddit |
    🌐 Website |
    🎵 TikTok |

     
    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi, thanks for your comment.

       

      Unfortunately, the 'application year string' column can contain the year '2020a', which is going to prevent me from using the number format. What else would you suggest?