Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
taskob
Frequent Visitor

ListName from parameter

Hi All,
I would like to use a Parameter (List_Param) instead of hardcoding the name of my list to filter out some of the rows from several tables in the model.

#"Remove Rows" = Table.SelectRows(#"Type modified", each try List.Contains(Element_list1, [ElementCode]) otherwise null = true)


I tried to replace Element_list1  with 

Expression.Evaluate(List_param, #shared) 

  -(List_param is set to Element_list1)- and it filters the rows in query editor, but when I close the query editor and refresh the data, my table will be empty.

How can I use my parameter List_Param to filter out rows from my table that aren't in the list named Element_list1?

Thanks!

1 ACCEPTED SOLUTION

You are right @taskob, but you can do it this way (it works also in Power BI)

 

I've hardcoded your lists into a table. See attached .pbix file.

dufoq3_0-1733503117702.png


Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

View solution in original post

8 REPLIES 8
PwerQueryKees
Super User
Super User

I do not know your use case, but there may be alternatives to Expression.Evaluate() you may want to consider, because Expression.Evaluate() sometimes causes security errors:

  • If you list is a column of a table you could use Table.Column to access it by name
  • If your list is a variable in your function, instead of assigning the name of the list to the parameter, assign the list to it.
  • if your list(s) are separate queries, combine them in 1 record that can be a sperate query.

 

[
   list 1 = {1,2,3},
   List 2 = {"a", "b", "c"}
}​

Acces any individual list with Record.Field

 

Hope this helps.

dufoq3
Super User
Super User

Hi @taskob, it is possible, but we don't know how do you store your lists for such parameter. Do you store them as a separate queries? 

 

You can do it this way for example. Check attached .xlsx file!

dufoq3_0-1733491506469.png


Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

taskob
Frequent Visitor

I see @dufoq3.  My version seems to work in Excel too (see attached) , but i need it to work in Power BI Desktop and Cloud too....
List_param.xlsx  

It works the same in Power BI Desktop. 

 

dufoq3_0-1733498047933.png

 


Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

taskob
Frequent Visitor

If you list the data from Element_values in a visualisation, it works for you? For me it's ok in Query editor, but no data in the visualisation.

You are right @taskob, but you can do it this way (it works also in Power BI)

 

I've hardcoded your lists into a table. See attached .pbix file.

dufoq3_0-1733503117702.png


Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

taskob
Frequent Visitor

Thank you!

You're welcome, enjoy 😉


Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.