Forum Discussion

ChrisDg's avatar
ChrisDg
Helper I
4 years ago
Solved

Sorting by number ranges

Hi,

 

I'm new to Power BI and I'm having issues sorting my x-axis for my column chart. This is the formula I used to get my index: 

 

Index =
SWITCH (
    'Company size_Report'[Company size],
    "1", 1,
    "2-10", 2,
    "11-50", 3,
    "51-200", 4,
    "201-500", 5,
    "501-1000", 6,
    "1001-5000", 7,
    "5001-10000", 8,
    9)
 
I've gone to the sort by index section in the data field: 
 

 

I've sorted the axis by company size and have not included the index in my visual. I was previously told to disable the sort completely (which I can't find out how to do that) and removing the company size field from the visual and adding it back. As an end result, I keep getting my graph looking like this: 

 

 

 

How do I get my graph to sort the way that I have it set up in my index?

 

Thank you,

 

Chris 

 

  • ChrisDg's avatar
    ChrisDg
    3 years ago

    Hi Winniz,

     

    I figured this out on Friday. Thank you for your response! I did the same thing. However, I will add that this solution won't be resolved unless you also drag the Index column into the Tooltips bar: 

     

     

     

    Thank you,

     

    Chris 

4 Replies

  • Sorry, I forgot to check sort axis by company size. It looks like this: 

     

     

     

    Thank you,

     

    Chris 

  • v-kkf-msft's avatar
    v-kkf-msft
    Community Support

    Hi ChrisDg ,

     

    First add the index column in the Power Query Editor, and then sort the [Company size] column by the Index column. Note that the index column needs to correspond to the value of [Company size] one by one.

     

    Sort one column by another column in Power BI 

     

     

     

    If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
    Best Regards,
    Winniz
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

     

    • ChrisDg's avatar
      ChrisDg
      Helper I

      Hi Winniz,

       

      I figured this out on Friday. Thank you for your response! I did the same thing. However, I will add that this solution won't be resolved unless you also drag the Index column into the Tooltips bar: 

       

       

       

      Thank you,

       

      Chris