Forum Discussion
Anonymous
2 years agoNot applicable
Extract specific text from a column
Hello, I have a column with some values Exemple : P1,A,P2 P2,B,C,P1 P3,A,P1,D,E,G Etc ... I only want to extract P1, P2 and P3 (the result of what i want to extract is known) ...
tackytechtom
2 years agoMost Valuable Professional
Hi Anonymous ,
Here one way of doing this:
Here the code in Power Query M that you can paste into the advanced editor (if you do not know, how to exactly do this, please check out this quick walkthrough)
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCjDUcdQJMFKK1QGyjXScdJx1AgwhPGOQjKGOi46rjrtSbCwA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [column = _t]),
#"Added Custom" = Table.AddColumn(Source, "Custom", each Text.Split([column], ",")),
#"Expanded Custom" = Table.ExpandListColumn(#"Added Custom", "Custom"),
#"Filtered Rows" = Table.SelectRows(#"Expanded Custom", each Text.Contains([Custom], "P1") or Text.Contains([Custom], "P2") or Text.Contains([Custom], "P3")),
#"Grouped Rows" = Table.Group(#"Filtered Rows", {"column"}, {{"newcolumn", each Text.Combine( [Custom], ","), type text}}
)
in
#"Grouped Rows"
Let me know, if this helps 🙂
/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/