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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
atpbi10
Helper I
Helper I

Remove certain string from text in the column

Hey!

How can I transform this column which contains certain string that starts with certain character which is in my case "PL"

 

Name
Jay Chua PL231221
John Cena
Arnold Black PL212233
Jack Don

 

To the one below? So essentially I need to remove all occurences of the string in the values based on condition.

 

Name
Jay Chua
John Cena
Arnold Black
Jack Don

 

Here is my attempt, where I created custom function but the code does not work as intended at all:

 

 

let
    Source = Excel.Workbook(File.Contents("***"), null, true),
    Sheet1_Sheet = Source{[Item="Sheet1",Kind="Sheet"]}[Data],
    #"Promoted Headers" = Table.PromoteHeaders(Sheet1_Sheet, [PromoteAllScalars=true]),
    #"Renamed Columns" = Table.RenameColumns(#"Promoted Headers",{{"WrongName", "Name"}}),
    #"Invoked Custom Function" = Table.TransformColumns(#"Renamed Columns", {"Name",  each if Text.Start(Text.From(_),2)="PL" then "" else _})
in
    #"Invoked Custom Function"

 

 

1 ACCEPTED SOLUTION
mahoneypat
Microsoft Employee
Microsoft Employee

You can add a custom column with this formula

 

= Text.Combine(List.Select(Text.Split([Name], " "), each not(Text.Contains(_, "PL"))), " ")

 

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

3 REPLIES 3
Anonymous
Not applicable

If the string to be deleted is at the end of the text (or better,if the text to keep is before the PLxyz pattern ), as in your examples, you can create a custom column in this way.

You could eventually change "PL" with " PL" to trim the trailing space

 

immagine.png

mahoneypat
Microsoft Employee
Microsoft Employee

You can add a custom column with this formula

 

= Text.Combine(List.Select(Text.Split([Name], " "), each not(Text.Contains(_, "PL"))), " ")

 

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Hey thanks for the solution, works properly. Just wanted to make sure if this is case sensitive? Like for the table in the example if I have guy named "Max Planck", he wont have his surname removed?

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 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.

Top Kudoed Authors