Hi,
I have been watching Melissa’s “Creating a custom text cleaning function in PQ” and I have managed to create an easy function. I have a lot of columns to clean up and am hoping to create another couple of functions but need some help please.
This is an example of my data:
I want to transform that one column into two columns:
The first extracts the text prior to the first bracket or if no bracket, just uses the text.
The second combines “SR” with the text between the first set of brackets. If there are no brackets, it returns blank.
I have managed to do this in pq by creating two new columns from examples but I would prefer it as a function as i have to use it for many columns.
My mcode is:
let
Source = Excel.CurrentWorkbook(){[Name=“Table5”]}[Content],
CustColumnName = Table.AddColumn(Source, “Name”, each let splitMgt = Splitter.SplitTextByDelimiter(" (", QuoteStyle.None)([Mgt]), splitsplitMgt0 = Splitter.SplitTextByDelimiter("(", QuoteStyle.None)(splitMgt{0}?) in splitsplitMgt0{0}?, type text),
CustColumnSRNumber = Table.AddColumn(CustColumnName, "SRNumber", each let splitMgt = Splitter.SplitTextByDelimiter("(", QuoteStyle.None)([Mgt]), splitsplitMgt1 = Splitter.SplitTextByDelimiter(")", QuoteStyle.None)(splitMgt{1}?) in Text.Combine({"SR", splitsplitMgt1{0}?}), type text)
in
CustColumnSRNumber
File is attached. Thanks for looking
Test function.xlsx (43.8 KB)