Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
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"
Solved! Go to Solution.
You can add a custom column with this formula
= Text.Combine(List.Select(Text.Split([Name], " "), each not(Text.Contains(_, "PL"))), " ")
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
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
You can add a custom column with this formula
= Text.Combine(List.Select(Text.Split([Name], " "), each not(Text.Contains(_, "PL"))), " ")
Pat
To learn more about Power BI, follow me on Twitter or subscribe 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?
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 5 | |
| 4 | |
| 3 | |
| 3 | |
| 2 |
| User | Count |
|---|---|
| 8 | |
| 6 | |
| 6 | |
| 6 | |
| 5 |