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
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
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.