Forum Discussion
Check string for values in other table
- 7 years ago
Say you have your posts in a table, then you can add a column with this formula:
List.First(List.Select(ListOfPotentialCompanies, (x) => Text.Contains([Post], x)))
You can also paste this code into the advanced editor to see how this works:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8kjMyclX8M1MLsovzk8rUYrViVbyVMjJL0tVCMgvTy1ScPJUio0FAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Post = _t]),
ListOfPotentialCompanies = {"Microsoft"},
#"Added Custom" = Table.AddColumn(Source, "Custom", each List.First(List.Select(ListOfPotentialCompanies, (x) => Text.Contains([Post], x))))
in
#"Added Custom"As you'll see, only the first value from the possible list of matches is selected, but you can omit that part of the formula if you want to retrieve all matches instead.
Ahh, in that case, ImkeF is your best bet!
Say you have your posts in a table, then you can add a column with this formula:
List.First(List.Select(ListOfPotentialCompanies, (x) => Text.Contains([Post], x)))
You can also paste this code into the advanced editor to see how this works:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8kjMyclX8M1MLsovzk8rUYrViVbyVMjJL0tVCMgvTy1ScPJUio0FAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Post = _t]),
ListOfPotentialCompanies = {"Microsoft"},
#"Added Custom" = Table.AddColumn(Source, "Custom", each List.First(List.Select(ListOfPotentialCompanies, (x) => Text.Contains([Post], x))))
in
#"Added Custom"
As you'll see, only the first value from the possible list of matches is selected, but you can omit that part of the formula if you want to retrieve all matches instead.
- Anonymous6 years agoNot applicable
Hi ImkeF !
I was having the exact same problem and I have tried your solution but I just can't refer "TheListofPotentialCompanies" in my M formula.
Any idea why? Thank you so much 🙂
- ImkeF6 years agoCommunity Champion
This video is not particularly good, but hopefully helpful: http://community.powerbi.com/t5/Webinars-and-Video-Gallery/Power-BI-Forum-Help-How-to-integrate-M-code-into-your-existing/m-p/179314
- Anonymous6 years agoNot applicable
Hi ImkeF ! Thank you so much for your help! I've ended up creating a list with the values I want to use so I can use it within the formula.
However, I still get an error when I type: List.First(List.Select(#"Lista Assinaturas", (x) => Text.Contains([Data Base], x))))
Any idea why?
Any help would be very welcome 🙂
Thank you!
Pedro