Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Sort column with numbers and text

Hello!  I'm seen answers to this kind of question but the closest solutions don't seem to work, so I'm asking for help, please.

 

I have a data set with about 700,000 rows (and growing).  One column has responses to questions.  Not every row has a question, and not every question has a response, so there are lots of nulls.  As well, since new responses are being created fairly regularly, I can't just list every answer and sort them to use as a sort column.

 

I tried this promising answer:  https://community.powerbi.com/t5/Desktop/Number-sorting-in-text-format/m-p/237256; I also got an issue with the REPT part, but since my numbers are no more than 2 digits, I was able to just add a 0 to the first digit to try that as a sort order.  Unfortunately, when I tried to use that, I got a circular logic error.

 

Is there some other way to force Power BI to sort a number as a number, even if it's formatted as text?  Or another trick or workaround you've found helpful?

 

Thank you!

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Thanks, Polly.  I should have been more clear - I apologize.  I have some numbers (1, 2, 3 and so on) and some words/phrases (1-2 years, Usually, Strongly agree and so on) in a column:

1

Strongly Agree

3

10

Disagree

 

Of course, the plain numbers are sorting like text, 1, 10, 11, 12, 2, 3 ,4 and so on.  

 

As I dug in, I found there was a lot more that I needed to do to organize this, so I found this option for a bulk replace value - haven't tried it yet, but it looks promising:  https://www.howtoexcel.org/bulk-replace-values/#:~:text=When%20inside%20the%20power%20query,press%20....

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Thanks, Polly.  I should have been more clear - I apologize.  I have some numbers (1, 2, 3 and so on) and some words/phrases (1-2 years, Usually, Strongly agree and so on) in a column:

1

Strongly Agree

3

10

Disagree

 

Of course, the plain numbers are sorting like text, 1, 10, 11, 12, 2, 3 ,4 and so on.  

 

As I dug in, I found there was a lot more that I needed to do to organize this, so I found this option for a bulk replace value - haven't tried it yet, but it looks promising:  https://www.howtoexcel.org/bulk-replace-values/#:~:text=When%20inside%20the%20power%20query,press%20....

Anonymous
Not applicable

Hi @Anonymous ,

I have created a simple sample, please refer to it to see if it helps you.

Create a column first.

NumExtract =
IF (
    LEFT ( 'Table'[Column1], 2 ) = "AA",
    ( MID ( 'Table'[Column1], 3, LEN ( 'Table'[Column1] ) - 1 ) ),
    'Table'[Column1]
)

Then create a measure.

Measure =
RANKX (
    ALL ( 'table' ),
    CALCULATE ( MAX ( 'table'[NumExtract] ) ),
    ,
    ASC,
    DENSE
)

vpollymsft_0-1649658926249.png

If I have misunderstood your meaning, please provide your pbix file without privacy information and your desired output.

 

Best Regards

Community Support Team _ Polly

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors