Forum Discussion
How to replace OR condition in power query M
- 4 years ago
Table.AddColumn(#"Rounded Off", "Active", each {"Not Relevant","Aspertame","Sucralose","Stevia","Half-Sugar"}{List.PositionOf({{"GOLD","GLD"},{"NATURA"},{"GREEN","GRN"},{"SUGARLITE"}},[MATERIAL DESC],0,(x,y)=>List.Contains(x,y,(x,y)=>Text.Contains(y,x)))+1) - 4 years ago
Hi monojchakrab ,
Missing a ")" in the syntax (after x[Case]).
Table.AddColumn(#"Added Custom2", "Custom", each try Table.SelectRows(LookupTable, (x)=> Text.Contains([MATERIAL DESC],x[Case]))[Return]{0}) otherwise "Not Relevant")
Hi monojchakrab ,
You don't need to add a need step as this is a replacement step to your existing code (i.e. the custom column).
I have added [MATERIAL DESC] and Text.Contains() to the code below:
try Table.SelectRows(Lookup, (x)=> Text.Contains([MATERIAL DESC],x[Case])[Return]{0} otherwise "Not Relevant"
Regards
KT
Hey KT_Bsmart2gethe , I tried this code as follows in a new custom column :
= Table.AddColumn(#"Added Custom2", "Custom", each try Table.SelectRows(LookupTable, (x)=> Text.Contains([MATERIAL DESC],x[Case])[Return]{0})
otherwise "Not Relevant")But this is returning tables in the custom column as below :
And the pop-up window when I am trying to expand the column..
Am I getting something wrong?
Appreciate your working with me on this
Thanks and best regds.,
- KT_Bsmart2gethe4 years agoImpactful Individual
Hi monojchakrab ,
Would you be able to screenshot the lookup table, including the name? Also, screenshot the preview of each sub-table, and if possible, the sample of column - [MATERIALS DESC].
Regards
KT
- monojchakrab4 years agoResolver III
Here goes...
The [Material Desc] column :
I have added number steps to the query - is there any specific step, from which you require the sub-table?
- KT_Bsmart2gethe4 years agoImpactful Individual
Hi monojchakrab ,
Missing a ")" in the syntax (after x[Case]).
Table.AddColumn(#"Added Custom2", "Custom", each try Table.SelectRows(LookupTable, (x)=> Text.Contains([MATERIAL DESC],x[Case]))[Return]{0}) otherwise "Not Relevant")- monojchakrab4 years agoResolver III
whoops KT_Bsmart2gethe ....it has worked this time. This is an elegant solution