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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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

Top Solution Authors
Top Kudoed Authors