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
EH_MW
Frequent Visitor

Pulling numeric-only values from a alphanumeric field

I am trying to do analysis and summarization of a "numeric" field in one of our systems. The issue is, when bringing it into Power BI, Power BI recognizes it as alphanumeric (rightfully so) so I am unable to do any math on it. It should be a numeric field and most people use it as such, but it is freeform in the system, so other users have entered values such as "TBD", "NA", "40M", etc. Is there any way for me to create a new column, excluding these alphanumeric values, and only pulling in the strictly numeric values, allowing me to do math on this new column?

1 ACCEPTED SOLUTION

 Yours is the simplest solution which can be done with just the interface.  However, if I were to do a custom column, it would be

// Attempts to convert the value in [column] to a number and returns null if it fails
try Number.From([column]) otherwise null

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

6 REPLIES 6
Ashish_Mathur
Super User
Super User

Hi,

Hope this helps.

Ashish_Mathur_0-1745373128400.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
kpost
Super User
Super User

Here's a solution that could be more elegant but it works: (All in Power Query).  I'm sure someone who is better at M language could combine this all into a single step but this is what I'd do.

 

-"Duplicate" the column

duplicate.PNG

-convert it to data type "Whole Number"

WHOLE.PNG

-"Replace Errors" with the number 0

 

REPLACE1.PNG

 

REPLACE2.PNG

-"Replace Values" where it is null with 0

 

REPLACE1.png

 

REPLACE2.PNG

 

 

All done!!

 

done.PNG

 

 

///Mediocre Power BI advice, but it's free///

 Yours is the simplest solution which can be done with just the interface.  However, if I were to do a custom column, it would be

// Attempts to convert the value in [column] to a number and returns null if it fails
try Number.From([column]) otherwise null

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
amitchandak
Super User
Super User

@EH_MW , There are a few options discussed here, see if those can help

https://goodly.co.in/separate-numbers-from-text-excel-powerquery/

https://excelguru.ca/separate-values-and-text/

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

These videos deal with splitting the value. I'm looking to create a new column that completely ignores the values that have an alpha value in them. I need to do this because there are values such as "40M" instead of "40,000,000". If I simply split off the the numers and letters, I would be left with 40. Our users would prefer to ignore these values altogether until the data is cleaned up.

Instead, I'm looking for a way to create a new column that uses the monetary value if it exists (numbers only) and, if alpha characters exist in the value, set those values to 0 or ignore them completely.

@EH_MW ,

  • Replace every “,” with an empty string, and remove all spaces (i.e., replace them with a zero‑length string).

  • Split the result into two columns at the first transition from a digit to a non‑digit.

  • Then, split the second column at the transition from a non‑digit back to a digit.

  • If the first column is not blank and the second column contains suffixes like “M” or “k,” apply your specific rule for those cases.

  • Define similar rules for any other suffixes or scenarios.

Provide me sample very similar to your sample I can put some code around it

 

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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