Forum Discussion
M language issue
OK..this makes no sense to me..I am trying to take a list of numbers and use them as part of a "List.Contains" for a filter...if I hardcode the number list as in:
each List.Contains({1,2,3...
the filter works perfectly but if I make the list a parameter, then source that it doesn't, even if I use other functions like "Value.From" or convert it using Binary.From or some other function..it doesn't error out, just doesn't work..what gives?
10 Replies
- Greg_DecklerCommunity Champion
When you change it to a parameter, are you sure you are feeding it a list and not a table?
- dslForPBIHelper I
Thanks for your response Greg_Deckler! I am sure it is not a table--which is why it seems like either an odd bug or something--here is a snippet of code with comments:
//Prep for filter using a parameter (outboundcodes) which is just a comma-delimited list of values
////
valForCodes = Value.FromText(outboundcodes),
//This one works (hardcoded)
tblIncludeStates = Table.SelectRows(tblFromDownload, each List.Contains({543,95,96,1359,1360,1104,1170,1172,93,1248,454,1361,92,97,-4,-3,-5,-7,-8,-2}, [Outstate_Code])),//This one doesn't (just results in an empty table
//
tblIncludeStates = Table.SelectRows(tblFromDownload, each List.Contains(valForCodes,[Outstate_Code])),- Greg_DecklerCommunity Champion
Try this:
//Prep for filter using a parameter (outboundcodes) which is just a comma-delimited list of values // // valForCodes = Text.ToList(Value.FromText(outboundcodes)), //This one works (hardcoded) tblIncludeStates = Table.SelectRows(tblFromDownload, each List.Contains({543,95,96,1359,1360,1104,1170,1172,93,1248,454,1361,92,97,-4,-3,-5,-7,-8,-2}, [Outstate_Code])), //This one doesn't (just results in an empty table // tblIncludeStates = Table.SelectRows(tblFromDownload, each List.Contains(valForCodes,[Outstate_Code])),