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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch 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
Impactful Individual
Impactful Individual

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.

Top Kudoed Authors