Hi,
Is the kg or lb Always at the End of the Text string ?
[SIZE=1]let
Source = Excel.CurrentWorkbook(){[Name="Table4"]}[Content],
#"Extracted Text After Delimiter" = Table.TransformColumns(Source, {{"Column1", each Text.AfterDelimiter(_, " ", {0, RelativePosition.FromEnd}), type text}}),
#"Inserted Last Characters" = Table.AddColumn(#"Extracted Text After Delimiter", "Last Characters", each Text.End([Column1], 2), type text),
#"Added Custom" = Table.AddColumn(#"Inserted Last Characters", "Custom", each Text.Trim([Column1],{"a".."z","A".."Z"})),
#"Merged Columns" = Table.CombineColumns(#"Added Custom",{"Custom", "Last Characters"},Combiner.CombineTextByDelimiter("", QuoteStyle.None),"Result"),
#"Removed Other Columns" = Table.SelectColumns(#"Merged Columns",{"Result"})
in
#"Removed Other Columns"[/SIZE]
99% of the time so I'd be happy with that yes!
Book1 | ||||
---|---|---|---|---|
A | B | |||
1 | SSRG POLYL P400E HCG DRST210kg | 210kg | ||
2 | SSRG POLYL P400E HCG DRST1045lb | 1045lb | ||
Sheet470 |
Cell Formulas | ||
---|---|---|
Range | Formula | |
B1 | =MID(RIGHT(SUBSTITUTE(A1," ",REPT(" ",99)),99),LOOKUP(118,MIN(FIND({0,1,2,3,4}+{0;5},RIGHT(SUBSTITUTE(A1," ",REPT(" ",99)),99)&1/17))),99) |
[SIZE=1]let
#"Uppercased Text" = Table.TransformColumns(Excel.CurrentWorkbook(){[Name="Table4"]}[Content],{{"Column1", Text.Upper, type text}}),
#"Split Column by Delimiter" = Table.ExpandListColumn(Table.TransformColumns(#"Uppercased Text", {{"Column1", Splitter.SplitTextByDelimiter(" ", QuoteStyle.Csv), let itemType = (type nullable text) meta [Serialized.Text = true] in type {itemType}}}), "Column1"),
#"Added Conditional Column" = Table.AddColumn(#"Split Column by Delimiter", "Custom", each if Text.Contains([Column1], "KG") then [Column1] else if Text.Contains([Column1], "LB") then [Column1] else null),
#"Merged Columns" = Table.CombineColumns(Table.AddColumn(Table.AddColumn(Table.SelectRows(#"Added Conditional Column", each ([Custom] <> null)), "Last Characters", each Text.End([Custom], 2), type text), "Custom.1", each Text.Trim([Custom],{"a".."z","A".."Z"})),{"Custom.1", "Last Characters"},Combiner.CombineTextByDelimiter("", QuoteStyle.None),"Result"),
#"Removed Other Columns" = Table.SelectColumns(#"Merged Columns",{"Result"})
in
#"Removed Other Columns"[/SIZE]
[SIZE=1]let
#"Uppercased Text" = Table.TransformColumns(Excel.CurrentWorkbook(){[Name="Table4"]}[Content],{{"Column1", Text.Upper, type text}}),
ExtractNumber = Table.TransformColumnTypes(Table.AddColumn(Table.SelectRows(Table.AddColumn(Table.ExpandListColumn(Table.TransformColumns(#"Uppercased Text", {{"Column1", Splitter.SplitTextByDelimiter(" ", QuoteStyle.Csv), let itemType = (type nullable text) meta [Serialized.Text = true] in type {itemType}}}), "Column1"), "Custom", each if Text.Contains([Column1], "KG") then [Column1] else if Text.Contains([Column1], "LB") then [Column1] else null), each ([Custom] <> null)), "Custom.1", each Text.Trim([Custom],{"A".."Z"})),{{"Custom.1", type number}}),
Convert2KG = Table.SelectColumns(Table.TransformColumns(Table.TransformColumnTypes(Table.AddColumn(ExtractNumber, "Result", each if Text.Contains([Custom], "LB") then [Custom.1]*0.453592 else [Custom.1]),{{"Result", type number}}),{{"Result", each Number.Round(_, 2), type number}}),{"Result"})
in
Convert2KG[/SIZE]