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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
Anonymous
Not applicable

Convert text to number

Hi everyone,

 

I would like to create a conditional formatting based on a text column. My data column contains a four digit base number. For example 1A1A, 1A1B,1A1C. 1A1A is smaller than 1A1B. Power BI can sort the column correctly, but I cannot use this column directly, since the data needs to be a number for the power bi to determine the minimum and maximum values. Thus, is there any way to assign a number ranking according to the base number column?

 

Your answer is well appreciated. 

1 ACCEPTED SOLUTION
v-henryk-mstf
Community Support
Community Support

Hi @Anonymous ,

 

According to your description, I think the easiest way is to create a column index based on the cardinality column as a sorting. Or use the "Replace Values" function in power query to replace the text in the column with a number, and then change the column type to a number.

vhenrykmstf_0-1627896036116.png

and you can read following document:

Table.ReplaceValue - PowerQuery M | Microsoft Docs


If the problem is still not resolved, please provide detailed error information and let me know immediately. Looking forward to your reply.


Best Regards,
Henry


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

View solution in original post

2 REPLIES 2
v-henryk-mstf
Community Support
Community Support

Hi @Anonymous ,

 

According to your description, I think the easiest way is to create a column index based on the cardinality column as a sorting. Or use the "Replace Values" function in power query to replace the text in the column with a number, and then change the column type to a number.

vhenrykmstf_0-1627896036116.png

and you can read following document:

Table.ReplaceValue - PowerQuery M | Microsoft Docs


If the problem is still not resolved, please provide detailed error information and let me know immediately. Looking forward to your reply.


Best Regards,
Henry


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

tex628
Community Champion
Community Champion

Hi, 

I'd say you need to create an additional column, which is completly numeric. Replace A with 01 and B with 02 and so on. 

You can do this either with a long Text.Replace statement or by creating a mapping table in excel which you then merge into the original table. 

/ J


Connect on LinkedIn

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 NL Carousel

Fabric Community Update - February 2025

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