Forum Discussion

webportal's avatar
webportal
Impactful Individual
9 years ago
Solved

Sort column with repeated values by another column.

Hello,

 

In Power BI Desktop, I'm trying to order the following column with repeated values by an ID column (contains primary key).

 

This returns the error: "There can't be more than one value in "Nível2"...." 

 

 

In this other post it seems the suggestion is to concatenate the values of the column so they don't get duplicate.

 

But I want them to be repeated so they can aggregate values in visuals.

 

So, what's the workaround for this situation?

 

Thanks in advance for helping!

  • webportal's avatar
    webportal
    9 years ago

    v-sihou-msft Thanks, I've figured out that too.

    The solution is to build a calculated column, using PATHITEM and PATH on [Nível2], thus preserving its independence.

    Then I can order by that column!

5 Replies

  • MattAllington's avatar
    MattAllington
    Community Champion

    The solution is simple. You just have a 1:1 match of the sort ID column to the Nivel2 column. So if you have 3 unique values in the Nivel2 column, you must have 3 unique values in the sort column with a 1:1 mapping

    • webportal's avatar
      webportal
      Impactful Individual

      Hello,

       

      Thanks, yes I know.

       

      I created the following Sort2 column:

       

      CALCULATE(MAX('Balancete'[ID]);ALLEXCEPT(Balancete;Balancete[Nível2]))

      But now I get the error message: "This column can't be ordered by a column that is already, directly or indirectly, ordered by this column".

      • v-sihou-msft's avatar
        v-sihou-msft
        Microsoft Employee

        webportal

         

        As the error message said, the result of this calculated column is based on your [Nível2] column. It's not possible to use this column to so sort [Nível2] back. To sort this column, we must have another independent column with unique values. 

         

        Regards,