Forum Discussion
JuanSombrero
9 years agoFrequent Visitor
Pass a list as filter argument in Power Query
Hi all, I have a fact table with transactions (sales and product numbers), and a second list of 'required product numbers'. This list is dynamic and can change every time I use the report. I want...
- 9 years ago
This would be the way:
= Table.SelectRows(factSales, each List.Contains(requiredProductNumbers, [Product]))
MarcelBeug
9 years agoCommunity Champion
This would be the way:
= Table.SelectRows(factSales, each List.Contains(requiredProductNumbers, [Product]))
- dslForPBI8 years agoHelper I
Not sure how this is the correct answer. Executing this results in:
Expression.Error: We cannot convert a value of type List to type Table.
Details:
Value=List
Type=TypeI tried doing the same thing and it produces as I have a list I am using to try and filter a table in the same way. Other examples mention trying to using a query parameter instead--seems like it is much more laborious than it should be.
- Anonymous8 years agoNot applicable
Having the same issue here, have been trying to figure this out all morning.
No luck! If someone could elaborate futher it would be appreciated greatly.
- dslForPBI8 years agoHelper I
Hello--sorry I missed this somehow--happy to oblige though!! Here is a code snippett below which should give you what you want:
////Use the parameter list to feed code values...//tblIncludeStates = Table.SelectRows(tblFromDownload, each List.ContainsAny({MyCodeList} ,{[Outstate_Code]})),..the "MyCodeList" is my list of codes..the "ContainsAny" is the m function/method that did the trick for me..you might also look at the type you used for the list and make sure it coincides with the type you are looking to iterate over.