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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
abellanc
Regular Visitor

Retain cells containing numbers while replacing others with “None”

I want to convert cells under EV that does not contain numbers to "None" and retain those that contains numbers. I tried below formula but "0".."9" portion shows an error. I replaced it with Text.Contains(_, "0123456789") but it changes all the cells to None.

 

#"Replace None" = Table.TransformColumns(Source", {{"EV", each if Text.Contains(_, "0".."9") then _ else "None"}})

 

abellanc_0-1720158049977.png

 

1 ACCEPTED SOLUTION
wdx223_Daniel
Super User
Super User

=Table.ReplaceValue(YourTable,"","",(x,y,z)=>if Text.Remove(Text.From(x),{"0".."9"})=x then "None" else x,{"EV"})

View solution in original post

6 REPLIES 6
abellanc
Regular Visitor

nice, thanks so much!

wdx223_Daniel
Super User
Super User

=Table.ReplaceValue(YourTable,"","",(x,y,z)=>if Text.Remove(Text.From(x),{"0".."9"})=x then "None" else x,{"EV"})

AlienSx
Super User
Super User

Table.TransformColumns(Source, {{"EV", each if Text.PositionOfAny(_, {"0".."9"}) <> -1 then _ else "None"}})
abellanc
Regular Visitor

Hi Pete, good day! Actually, there are a lot to be replaced like n\a, N\A, NA, not available, No data, NO DATA, ND, etc. Power Query, as I believe, is case sensitive to I have a lot to add. The users would also erroneously input data that may not be on the list.

 

Yes, fair enough. Wasn't sure if the example you provided showed all the exception possibilities or not.

PQ is case sensitive, that's why I've used "Text.Lower([EV])" as the comparison value - a neat trick to deal with exactly this issue in PQ.

Looks like @AlienSx has provided a really nice neat solution, so you're sorted anyway 👍

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




BA_Pete
Super User
Super User

Hi @abellanc ,

 

It's a little bit of a hack, but you may find it way simpler just to replace the "N/A"s with "None", something like this:

 

Table.ReplaceValue(
    PreviousStepName,
    each [EV],
    each if List.Contains({"na", "n/a"}, Text.Lower([EV])) then "None" else [EV],
    Replacer.ReplaceText,
    {"EV"}
)

 

If this doesn't work as-is, then try changing Replacer.ReplaceText for Replacer.ReplaceValue.

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




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