Forum Discussion
Add Column based on other table columns value
Hi!
Need your help with simple task..
I have 2 tables with no relations between them:
#Table1({"ColumnA", "ColumnB"}, {{1,Green Apple },{2,Red Potato},{3,Blue Star},{4,Kung Fu Panda}})
#Table2({"ColumnC", "ColumnD"}, {{apple, fruit},{potato, vegetable},{star, astronomical object},{kung fu, martial art}})
The goal is to add ColumnE to Table1 with this condition:
if Text.Contains(Table1[ColumnB, Table2[ColumnC]) then Table2[ColumnD] else null
The result should be:
#Table1({"ColumnA", "ColumnB","ColumnE"}, {{1,Green Apple , fruit},{2,Red Potato, vegetable},{3,Blue Star, astronomical object},{4,Kung Fu Panda, martial art}})
This perfectly works with manual static if blocks, but I have no idea how to automate this task using values from table.
Any ideas?
This is what I looked for: https://eriksvensen.wordpress.com/2019/02/28/powerquery-replicate-doing-an-excel-vlookup-in-m/
Thanks to @amitchandak
6 Replies
- Greg_DecklerCommunity Champion
- BublicNew Member
In my casev LOOKUPVALUE is not working without relationship(
- BublicNew Member
Column B can contain value like : "The biggest green apple all over the world". How can I guess which splitted column to use?
- Pragati11Super User
Hi Bublic ,
In that case, you shared the wrong sample data to your issue.
Go with the option suggested by Greg_Deckler .
Thanks,
Pragati
- BublicNew Member
This is what I looked for: https://eriksvensen.wordpress.com/2019/02/28/powerquery-replicate-doing-an-excel-vlookup-in-m/
Thanks to @amitchandak