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
Shobs15
Regular Visitor

Remove a substring of only letters in a string of alphanumerics in Power query

Hi Dear Community Members

I have a below use case where I want to remove any substring separated with a space and has only letters in it. Please see the Output column below. Is this something achievable in Power query or dax in Powerbi? The problem is the substring with just alphabets can be of any length and placed anywhere in the String column.

Thank You!

StringOutput
123/4F01 abc/def 346 54789/6201123/4F01 346 54789/6201
wqs/def 123/4F01 346 54789/6201123/4F01 346 54789/6201
123/4F01 346 abc/def 54789/6201123/4F01 346 54789/6201
123/4F01 346 54789/6201 abc/def123/4F01 346 54789/6201
1 ACCEPTED SOLUTION
Bibiano_Geraldo
Super User
Super User

hi, @Shobs15 , please try to use the following M code:

Table.AddColumn(#"Previous Step", "Cleaned Output", each 
Text.Trim(
    Text.Combine(
        List.Select(Text.Split([String], " "), 
            each Text.Contains(_,"0") or Text.Contains(_,"1") or Text.Contains(_,"2") or Text.Contains(_,"3") or 
                 Text.Contains(_,"4") or Text.Contains(_,"5") or Text.Contains(_,"6") or Text.Contains(_,"7") or 
                 Text.Contains(_,"8") or Text.Contains(_,"9") 
        ), " "
    )
))


Note: Make sure to replace [String] with your own field.
 

View solution in original post

1 REPLY 1
Bibiano_Geraldo
Super User
Super User

hi, @Shobs15 , please try to use the following M code:

Table.AddColumn(#"Previous Step", "Cleaned Output", each 
Text.Trim(
    Text.Combine(
        List.Select(Text.Split([String], " "), 
            each Text.Contains(_,"0") or Text.Contains(_,"1") or Text.Contains(_,"2") or Text.Contains(_,"3") or 
                 Text.Contains(_,"4") or Text.Contains(_,"5") or Text.Contains(_,"6") or Text.Contains(_,"7") or 
                 Text.Contains(_,"8") or Text.Contains(_,"9") 
        ), " "
    )
))


Note: Make sure to replace [String] with your own field.
 

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.