Forum Discussion
Using a list parameter as a table filter in M language
I have an M language query in which I would like to use list values from a parameter list. Each attempt causes only the default or current item to be read. Is it possible to pull all the items from the list? This is preferred rather then having a hard-coded number of items. Here is a code snippet:
//Trying to have all the 'QryCodes' evaluated as if they were included in this way...
//tblIncludeStates = Table.SelectRows(tblFromDownload, each List.Contains({{543,95,96,1359,1360,1104},[Outstate_Code]))
//
tblIncludeStates = Table.SelectRows(tblFromDownload, each List.Contains(QryCodes,[Outstate_Code]))
You nee to use List.ContainsAny() function. *** MAKE SURE you wrap your field name in curly brackets.
= Table.SelectRows(
PreviousStep,
each List.ContainsAny( { 543,95,96,1359,1360,1104 } , { [CodeValueField] }
))Results returned :
543 95 96 1359 1360 1104 where CodeValueField field contains all the values below:
CodeValueField
543 95 96 1359 1360 1104 1170 1172 93 1248 454 1361 92 97 -4 -3 -5 -7 -8 -2
11 Replies
- nickchobotar
Skilled Sharer
You will have to create a separate list of all of your parameters and then invoke your query as a separate custom function. Here is an example
https://www.youtube.com/watch?v=iiNDq2VrZPY // 12 minute describes multiple parameters
Nick-
- dslForPBI
Helper I
Thanks for the reply...the only parameter which is relavant for me in my case is list of values, as i have list of values I need to pass to evaluate. I have searched and it appears creating a function is what is suggested. Any examples of a custom function which takes a list as an arguement or at least tap into elements in the list (like "mylist[i]").
- nickchobotar
Skilled Sharer