Forum Discussion
Power Query: If (nested or second table) contains statement
- Oct 09, 2021
That could be like this, our queries are
Lookup keep as it is.
In Main query add column with list of keywords by Text.Split() of Keywords field.
Reference Lookup and create Not Contains keeping only Result and Not Contain columns, unpivot the latest, Group by Result without aggregation keeping only Values column. Thus we have list of Not Contain words for each Result (if exists)
Similar for Contains
Merge both above to have both lists in one List Combined table
Reference Main query as Final, add above Lookup Combined table to new column here
and expand it.
Add new custom column to check KeywordsList against Contains/Not Contains
Group by initial columns without aggregation keeping in resulting table of each group only rows where previous value is true.
Expand Result from it
and finally combine with Prediction
Details are in attached file.
SergeiBaklan Thank you for looking at this!
What I was saying by that structure was, I would like to be able to have the statement say: it say if it contains Lemon and Sugar but does not contain Orange then result is lemonade.
However, in retrospect I think it would be best formatted this way.
| Contain | AlsoContain | NotContain | Result |
| Lemon | Sugar | Orange | Lemonade |
Thank you. I hope I understand the idea, but depends on how your data is represented Power Query could be totally different.
- Joe_JLOct 08, 2021Copper ContributorI appreciate your help, would it be helpful If I created a demo table structure in Power Query?
- SergeiBaklanOct 08, 2021Diamond Contributor
Yes, that will be great. Sample file is always welcome.
- Joe_JLOct 08, 2021Copper Contributor
I have attached a sample file below (with the end results filled in, but obviously remove those as needed). Thank you again!