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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
Kaizu80
Frequent Visitor

Extract text, Power query issue

Hi!

 

I have a column in my raw data with item names in it, like this:

WID S 56*45

S 36*7

S56*27

QVJE S 36*14L

 

Is there a way to extract from that column the text before and after "*"? so that the result from the above would be:

S 56*45

S 36*7

S56*27

S 36*14L

 

BR

Kaj

1 ACCEPTED SOLUTION
v-yuezhe-msft
Microsoft Employee
Microsoft Employee

@Kaizu80,

Add a blank query in your PBIX file, then paste the following code to Advanced Editor of the blank query.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCvd0UQhWMDXTMjFVitWJVgpWMDbTMocwgaJGEGZgmJerAljK0MRHKTYWAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Changed Type", "Column1", Splitter.SplitTextByDelimiter("*", QuoteStyle.Csv), {"Column1.1", "Column1.2"}),
    #"Added Custom1" = Table.AddColumn(#"Split Column by Delimiter", "Custom.1", each if Text.Start([Column1.1], 1)="S" then [Column1.1] else Text.End([Column1.1], Text.PositionOf([Column1.1], "S"))),
    #"Added Custom" = Table.AddColumn(#"Added Custom1", "Custom", each [Custom.1] & "*" & [Column1.2])
in
    #"Added Custom"

1.JPG

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-yuezhe-msft
Microsoft Employee
Microsoft Employee

@Kaizu80,

Add a blank query in your PBIX file, then paste the following code to Advanced Editor of the blank query.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCvd0UQhWMDXTMjFVitWJVgpWMDbTMocwgaJGEGZgmJerAljK0MRHKTYWAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Changed Type", "Column1", Splitter.SplitTextByDelimiter("*", QuoteStyle.Csv), {"Column1.1", "Column1.2"}),
    #"Added Custom1" = Table.AddColumn(#"Split Column by Delimiter", "Custom.1", each if Text.Start([Column1.1], 1)="S" then [Column1.1] else Text.End([Column1.1], Text.PositionOf([Column1.1], "S"))),
    #"Added Custom" = Table.AddColumn(#"Added Custom1", "Custom", each [Custom.1] & "*" & [Column1.2])
in
    #"Added Custom"

1.JPG

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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