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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Clean data to only Integers

Hello all

 

I have a data set that contains a mixture of integers and strings, all attempting to indicate a value (e.g 1, one, 01).

 

There are also some erroneous inputs, like e3.

 

What's the best practice for cleaning this data?

 

The data set is constantly updated, so I can't simply filter. I'm happy to mark the inavlid inputs as N/A but I need the data cleansed to only the Integers so I can run formulae. 

1 ACCEPTED SOLUTION

hi, @Anonymous

    If you want to Conversion values like "Five" to integers, you need a conversion table like this:

24.PNG

then do these as below:

step1:

use this formula to add a column

try Number.From([Column1]) otherwise 0

Step2:

merge basic table with conversion table 

25.PNG

expand the table

26.PNG

Step3:

add a conditional column

28.PNG

 

Result:

29.PNG

 

here is pbix, please try it.

https://www.dropbox.com/s/hy5kcg8b1sgidnb/Clean%20data%20to%20only%20Integers.pbix?dl=0

 

Best Regards,

Lin

 

 

Community Support Team _ Lin
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

9 REPLIES 9
Anonymous
Not applicable

In the query edior I duplicated the column, then changed the data type to Decimal Number, then used the "Replace Errors" function to make all the strings 0.

 

It's a bit wanton so would like to hear any other approaches.

Greg_Deckler
Community Champion
Community Champion

Is it OK to remove the rows that would be errors?



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

@Greg_Deckler

Ideally I would like to convert the numbers as strings (written words) to integers without writing some huge IF statement that accounts for every number.

 

If that's not possble though, then yes, I would simply remove all the errors.

May be something like...

= try Number.From([Column]) otherwise 0
Anonymous
Not applicable

That works at converting the numbers that are formatted nicely, but doesn't do written numbers unfortunately.

Wait... so you have some field with value like "Five" and need that converted to 5?

 

Hmm, can't think of way to do this, except with separate conversion table.

Anonymous
Not applicable

Correct, I was hoping for a function to do it, but doesn't look like such exists. Coversion table it is!

hi, @Anonymous

    If you want to Conversion values like "Five" to integers, you need a conversion table like this:

24.PNG

then do these as below:

step1:

use this formula to add a column

try Number.From([Column1]) otherwise 0

Step2:

merge basic table with conversion table 

25.PNG

expand the table

26.PNG

Step3:

add a conditional column

28.PNG

 

Result:

29.PNG

 

here is pbix, please try it.

https://www.dropbox.com/s/hy5kcg8b1sgidnb/Clean%20data%20to%20only%20Integers.pbix?dl=0

 

Best Regards,

Lin

 

 

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

@v-lili6-msft

Thank you for the very comprehensive answer

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.