Forum Discussion

Sea_and_Anne's avatar
Sea_and_Anne
Icon for Helper I rankHelper I
9 years ago
Solved

sort by index order

Hello,

I want to sort the data in the graphics by the index number, but it never appears in the correct way. C

So i have a column with the measures that are in this formula " 1 - name of measure" "2- name of mesure" ....."12-name of mesure"
I have created one new column that is only the number of measure "1","2",...,"12" and sorted by this new column and added a index to order the data. However in my graphs appears every time in other orther..could you please help me?



thanks in advance.

 

 

  • TomMartens's avatar
    TomMartens
    9 years ago

    Hmm,

     

    maybe I'm still not getting the point ...

     

    A simple bar chart looks like this:

     

     

    I'm sorting the column Measure by Column1, these are the steps

    • select the data tab
    • select the column: Measure
    • "Sort By Column": choosing "column1"

     

     

    I'm getting this:

     

     

    Finally I'm applying a Visual Filter to avoid the Total Measure, this may be necessary, due to the fact that blank values (Measure: Total) are sorted before the measures that have a proper value in the column Column1

     

     

    If this is not what you want, I guess you have to explain the outcome a little more.

     

    Two questions:

    What kind of visualization are you using (in my example I'm using "Clustered Bar Chart"

    and what release of Power BI Desktop are you using.

10 Replies

  • austinsense's avatar
    austinsense
    Icon for Impactful Individual rankImpactful Individual

    If your index has the data type "Text" then it will sort like this ... { 1, 10, 11, 2, 3, 4 ... }

     

    Two options to fix it:

    1. Change the data type to "Whole Number" - currently it might be "Text" or "Any"
    2. Keep the data type of the field "Text" but make the records look like this { 01, 02, ... 11, 12 } - that will sort correctly as text

     

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Sea_and_Anne,

    How do you use the “sort by column” feature in Power BI Desktop?  Firstly, in Query Editor, please add a index column to your table as shown in the following screenshot.


    After clicking “Close & Apply”, in Report view, choose the column dragged into Axis in Fields panel, then click  “Sort By Column” and choose Index under Modeling ribbon.


    Then check if your visual displays as expected.



    Thanks,
    Lydia Zhang

    • Sea_and_Anne's avatar
      Sea_and_Anne
      Icon for Helper I rankHelper I

      Hello,
      Thank you for the solutions.
      I tried both but i didn't got the expected result.
      I've sorted by index in "Data" window but when i go to the report the "sort by" button is not active.

       

       


      Could you please help solving this issue?

      Thanks in advance,
      :)

      • TomMartens's avatar
        TomMartens
        Icon for Super User rankSuper User

        Hey,

         

        as I understand you want to sort one column by another column.

         

        In the DataView select the column that you want to be sorted. Then choose from the "Sort by Column" Menu the proper column that contains the index.

         

         

        Hope this helps