How to Use Query Parameters in M

This is a follow up to my previous post, How to Retrieve Data Recursively with Power BI. It is meant to show how to use Query Parameters as part of your M scripts.

Assuming that you read my previous blog, you should have a working Power Query environment ready to use.

Let us first create a parameter using the Power BI desktop user interface.

In the Query Editor window click Manage Parameters from the ribbon.

Create Parameter

Now fill out the Parameter Form as shown below.

Fill out Parameter Form

We can now reference the new parameter from the M script. The picture below shows where the parameter was first set and then used.

Use Parameter

The Current Value of the parameter can be reset at any time. Once data is refreshed you will get the result form the User group you set the parameter value for.

Set Current Value

Happy coding.