Forum Discussion
Anonymous
3 years agoNot applicable
look up semicolon seperated text from another table without split function
Hi, I am a newbie to the powerBI tool. I would like to seek community help to get some guidance on how to achieve the Requirement on power BI power query. I have a table that has a product column ...
- 3 years ago
I think we can do this more simply than Vijay_A_Verma suggests.
Take the first element of the intersection of Table2[Prod List] and the products in the current row.List.First(List.Intersect({Table2[Prod List], Text.Split([Product], ";")}))Here's a fully self-contained variation of this query:
let Table1 = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCkgsKEisTFRIL0pNzbN2LCjISdXwTizOyM0s0lSK1UFX4J1ZnqmgEZqSmKegEVySmJei4JiTn5eqiU2tV2JytrV/UWJeeioW2YD83HygGampKTmpxcXYTHNKzANCBY2g1BSgQCwA", BinaryEncoding.Base64), Compression.Deflate)), type table [Product = (type text)]), Table2 = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("bcxBCsIwEIXhq4SuUvASVUGwC4viqnTxaB61mExCUije3pC4lNl8/MzMODZXzO9mOoxNF4Kl7pFebo1tSWdsTEWnnLkXDggBH6glklJKv+6r0k8DUfqxQYzqrBe29ckRkkfpO00Ng3c+L5LGMqV/J5bO19eO9qdLRGDRDKm4RciSOX0B", BinaryEncoding.Base64), Compression.Deflate)), type table [#"Prod List" = (type text)]), ProdList = List.Buffer(Table2[Prod List]), #"Added Custom" = Table.AddColumn(Table1, "Mapped Product List", each let CurrRowProds = Text.Split([Product], ";"), SharedProds = List.Intersect({ProdList, CurrRowProds}) in List.First(SharedProds), type text ) in #"Added Custom"
AlexisOlson
Super User
3 years agoI think we can do this more simply than Vijay_A_Verma suggests.
Take the first element of the intersection of Table2[Prod List] and the products in the current row.
List.First(List.Intersect({Table2[Prod List], Text.Split([Product], ";")}))
Here's a fully self-contained variation of this query:
let
Table1 = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCkgsKEisTFRIL0pNzbN2LCjISdXwTizOyM0s0lSK1UFX4J1ZnqmgEZqSmKegEVySmJei4JiTn5eqiU2tV2JytrV/UWJeeioW2YD83HygGampKTmpxcXYTHNKzANCBY2g1BSgQCwA", BinaryEncoding.Base64), Compression.Deflate)), type table [Product = (type text)]),
Table2 = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("bcxBCsIwEIXhq4SuUvASVUGwC4viqnTxaB61mExCUije3pC4lNl8/MzMODZXzO9mOoxNF4Kl7pFebo1tSWdsTEWnnLkXDggBH6glklJKv+6r0k8DUfqxQYzqrBe29ckRkkfpO00Ng3c+L5LGMqV/J5bO19eO9qdLRGDRDKm4RciSOX0B", BinaryEncoding.Base64), Compression.Deflate)), type table [#"Prod List" = (type text)]),
ProdList = List.Buffer(Table2[Prod List]),
#"Added Custom" = Table.AddColumn(Table1, "Mapped Product List", each
let
CurrRowProds = Text.Split([Product], ";"),
SharedProds = List.Intersect({ProdList, CurrRowProds})
in
List.First(SharedProds),
type text
)
in
#"Added Custom"- Vijay_A_Verma3 years ago
Most Valuable Professional
AlexisOlson Brilliant stuff!!!
- Anonymous3 years agoNot applicable
Thanks AlexisOlson for providing the optimized solution.