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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

How to use parameter as a dynamic list

Hi guys,

 

I have a custom column with a function like this:

 

= if List.Contains(List, [Column1.1]) then [Index] else null

 

The List is a variable I created in a step within a query. Is there any way I can pass this list into a Parameter instead of a Step? It will be much easier for users to input different lists. The data type of Parameter does not include List, however.

 

List.PNG

 

1 ACCEPTED SOLUTION
PhilipTreacy
Super User
Super User

Hi @Anonymous 

You could create your parameter and require it to be text, and provide your users with a description that it must be comma separated.  Presumably you'd also tell them this before they used the query.

You can then try to split the parameter into a list

 

TheList = Text.Split(TextList, ",")

 

You could wrap this in try..otherwise to catch errors or just let it fail naturally - but usually best to handle errors if you can.

You will also need to do any other parsing as required to check for invalid input.

https://docs.microsoft.com/en-us/powerquery-m/m-spec-error-handling

Regards

Phil


If I answered your question please mark my post as the solution.
If my answer helped solve your problem, give it a kudos by clicking on the Thumbs Up.



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


View solution in original post

2 REPLIES 2
PhilipTreacy
Super User
Super User

Hi @Anonymous 

You could create your parameter and require it to be text, and provide your users with a description that it must be comma separated.  Presumably you'd also tell them this before they used the query.

You can then try to split the parameter into a list

 

TheList = Text.Split(TextList, ",")

 

You could wrap this in try..otherwise to catch errors or just let it fail naturally - but usually best to handle errors if you can.

You will also need to do any other parsing as required to check for invalid input.

https://docs.microsoft.com/en-us/powerquery-m/m-spec-error-handling

Regards

Phil


If I answered your question please mark my post as the solution.
If my answer helped solve your problem, give it a kudos by clicking on the Thumbs Up.



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Anonymous
Not applicable

Thanks Philip, wonderful solution!

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

Top Solution Authors
Top Kudoed Authors