Forum Discussion
Extracting text
I have a column that contains supplier names in 2 formats
| Supplier Request for INX Corporation Pte Ltd on 03/09/2023 12:42 AM |
| Supplier Request for Vitcomm on 03/12/2023 06:11 AM |
| Supplier Registration for CEMIKA PTE. LTD. |
| Supplier Registration for CREATE LTD |
What is the easiest way to extract the supplier name from this column ?
Hi gancw1,
One possible approach to extract the supplier name from this column is to use Power Query in Excel or Power BI. Here are the steps:
Select the column that contains the supplier names.
Click on the "Transform data" button to open the Power Query Editor.
Click on the drop-down arrow next to the column header and select "Split Column" -> "By Delimiter".
In the "Split Column" dialog box, select "Custom" as the delimiter option and enter "for " (including the space after "for") as the delimiter text.
Click on "OK" to split the column into two separate columns.
Rename the new columns to something meaningful, such as "Action" and "Supplier".
Delete the "Action" column, as it is no longer needed.
Click on the drop-down arrow next to the "Supplier" column header and select "Trim" to remove any leading or trailing spaces.
Click on "Close & Load" to save the changes and return to the Excel or Power BI interface.
The resulting "Supplier" column should now contain the extracted supplier names. You may need to do some additional cleaning or formatting depending on the specific requirements of your analysis.
Best regards,
Isaac Chavarria
If this post helps, then please consider Accepting it as the solution and give Kudos to help the other members find it more quicklyI have figured out I can use the TextBetweenDelimiter() function to extract the supplier name by using "for " and " on" as start and end delimiters
= Table.AddColumn(#"Changed Type", "Supplier", each Text.BetweenDelimiters([Text], "for ", " from", 0, 0))
8 Replies
- ichavarriaSolution Specialist
Hi gancw1,
One possible approach to extract the supplier name from this column is to use Power Query in Excel or Power BI. Here are the steps:
Select the column that contains the supplier names.
Click on the "Transform data" button to open the Power Query Editor.
Click on the drop-down arrow next to the column header and select "Split Column" -> "By Delimiter".
In the "Split Column" dialog box, select "Custom" as the delimiter option and enter "for " (including the space after "for") as the delimiter text.
Click on "OK" to split the column into two separate columns.
Rename the new columns to something meaningful, such as "Action" and "Supplier".
Delete the "Action" column, as it is no longer needed.
Click on the drop-down arrow next to the "Supplier" column header and select "Trim" to remove any leading or trailing spaces.
Click on "Close & Load" to save the changes and return to the Excel or Power BI interface.
The resulting "Supplier" column should now contain the extracted supplier names. You may need to do some additional cleaning or formatting depending on the specific requirements of your analysis.
Best regards,
Isaac Chavarria
If this post helps, then please consider Accepting it as the solution and give Kudos to help the other members find it more quickly- gancw1Resolver II
Thanks. Yes use split by delimiter twice, once with "for " and followed up with " from" will extract the supplier name
- Ashish_MathurSuper User
Hi,
This M code works
let Source = Excel.CurrentWorkbook(){[Name="Data"]}[Content], #"Inserted Text Between Delimiters" = Table.AddColumn(Source, "Supplier name", each Text.BetweenDelimiters([Remarks], " ", " "), type text) in #"Inserted Text Between Delimiters"Hope this helps.
- gancw1Resolver II
I am not getting the same result. Asking for the text between 2 " " will return the 2nd word
#"Inserted Text Between Delimiters" = Table.AddColumn(Source, "Supplier name", each Text.BetweenDelimiters([Remarks], " ", " "), type text)
Can you share your PBIX file ?
- Ashish_MathurSuper User
Hi,
That M code got generated automatically when i used the "Column from Examples" feature. Please use that feature.
- gancw1Resolver II
I have figured out I can use the TextBetweenDelimiter() function to extract the supplier name by using "for " and " on" as start and end delimiters
= Table.AddColumn(#"Changed Type", "Supplier", each Text.BetweenDelimiters([Text], "for ", " from", 0, 0))