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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
PowerBtm
New Member

Match strings only composed of digits or letters, and remove the unwanted chars?

Hi! I need some help with Powerquery. I'm trying to remove all extraneous characters from a given input string so that there are only digits and letters left, but I don't really know if that's possible without access to regex. Does anyone have any ideas?

1 ACCEPTED SOLUTION
CNENFRNL
Community Champion
Community Champion

Simple enough,

 

= Text.Select("!~cl3509af;J8Ea""@6O4c", {"0".."9","a".."z","A".."Z"})

 

Screenshot 2021-06-08 224215.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

View solution in original post

2 REPLIES 2
CNENFRNL
Community Champion
Community Champion

Simple enough,

 

= Text.Select("!~cl3509af;J8Ea""@6O4c", {"0".."9","a".."z","A".."Z"})

 

Screenshot 2021-06-08 224215.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

AlB
Super User
Super User

Hi @PowerBtm 

Place the following M code in a blank query to see the steps.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WKix3UDY0MlZxC1KKjQUA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}),
    
#"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each List.Select(Text.ToList([Column1]), each List.Contains({"A".."Z"} & {"a".."z"} & {"0".."9"}, _))),

    #"Extracted Values" = Table.TransformColumns(#"Added Custom", {"Custom", each Text.Combine(List.Transform(_, Text.From)), type text})
in
    #"Extracted Values"

 

SU18_powerbi_badge

Please accept the solution when done and consider giving a thumbs up if posts are helpful. 

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors