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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
Anonymous
Not applicable

Power query. Returning a substring from another column.

Hi guys. I've trying to find a way to separate a part of a text, but I cant find. I have a random sentence that it has a word I want. This word allways have the pattern: letter-letter-number-letter, Examples: 13A7, 25E9, 63B8...

This are an example of text from where I want to extract:

 

Text column: "The product 8361529 with batch code 13A7 have the issue number 24865"

Return column: "13A7"

 

Please imagine this in power query.

Thank you guys and sorry for my bad english.

 

1 ACCEPTED SOLUTION
Jakinta
Solution Sage
Solution Sage

You can paste this to new blank query and adjust to your query.

2nd step looks for all words of length 4, containing 3 digits with letter on 3rd position.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCslIVSgoyk8pTS5RsDA2MzQ1slQwBQKF8sySDIWkxJLkDIXk/JRUBUNjR3OFjMSyVIUSoJbM4uLSVIW80tyk1CIFIxMLM1OlWB3spqEbZGLpSh2DTE3dzahikKGhjylVDDI2C7CkThgZhZpQxSADg0gL/AbFAgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Text = _t]),
    #"Added Custom" = Table.AddColumn(Source, "Return", each List.Select( Text.Split ( [Text], " "), each Text.Length(_)=4 and Text.Length( Text.Select(_,{"0".."9"}))=3 and List.Contains({"A".."Z"},Text.ToList(_){2}) ) ),
    #"Expanded Return" = Table.ExpandListColumn(#"Added Custom", "Return")
in
    #"Expanded Return"

Result:

Jakinta_0-1633410981186.png

 

View solution in original post

1 REPLY 1
Jakinta
Solution Sage
Solution Sage

You can paste this to new blank query and adjust to your query.

2nd step looks for all words of length 4, containing 3 digits with letter on 3rd position.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCslIVSgoyk8pTS5RsDA2MzQ1slQwBQKF8sySDIWkxJLkDIXk/JRUBUNjR3OFjMSyVIUSoJbM4uLSVIW80tyk1CIFIxMLM1OlWB3spqEbZGLpSh2DTE3dzahikKGhjylVDDI2C7CkThgZhZpQxSADg0gL/AbFAgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Text = _t]),
    #"Added Custom" = Table.AddColumn(Source, "Return", each List.Select( Text.Split ( [Text], " "), each Text.Length(_)=4 and Text.Length( Text.Select(_,{"0".."9"}))=3 and List.Contains({"A".."Z"},Text.ToList(_){2}) ) ),
    #"Expanded Return" = Table.ExpandListColumn(#"Added Custom", "Return")
in
    #"Expanded Return"

Result:

Jakinta_0-1633410981186.png

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

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.