How To Use Parameters In Power BI

Introduction

 
In the previous article ‘Parameters In Power BI Desktop,’ I have written about query parameters and how to create a parameter.
 
In this article, I will use that parameter (in my case it was ‘Database’). I have two databases in my SQL Server i.e. ‘MyDB’ and ‘AdventureWorks’. In the ‘MyDB’ database, I have two tables ‘Department’ & ‘Employees’ and in ‘AdventureWorks’ I have only one table ‘SalesPerson’.
 
How To Use Parameters In Power BI
 
My task is to import these tables in Power Query editor using my parameter. So, try the below steps:
 
Step 1
 
Let’s have a look at the parameter in power query editor in the below image:
 
How To Use Parameters In Power BI 
 
How To Use Parameters In Power BI
 
Now I will import data from the SQL server. To do so click on ‘New Source’ and select ‘SQL server’
 
How To Use Parameters In Power BI
 
After clicking on the SQL server source, you will find a new window of the SQL server database. Here, you should provide the Server Name and Database. In the database option, I will choose ‘Parameter’. See the below image
 
How To Use Parameters In Power BI 
 
How To Use Parameters In Power BI
 
Now click on ‘Ok’. Give the alternate credential or choose ‘Use my current credentials’ and then click on ‘Connect’.
 
How To Use Parameters In Power BI
 
Select the checkbox of the table and click on ‘Ok’.
 
How To Use Parameters In Power BI
 
Once you click on ‘Ok’ you can see that your table or tables of the given database will be showing on the left side of the editor window. In my case, I have only one table in my ‘AdventureWorks’ database. See the below image.
 
How To Use Parameters In Power BI
 
Step 2
 
Now I will modify my parameter to access the tables of another database i.e. ‘MyDB’.To do so go to the parameter and click on ‘Manage Parameter’.
 
How To Use Parameters In Power BI
 
Change the current value and select ‘MyDB’.
 
How To Use Parameters In Power BI
 
Now go to ‘New Source’ and click on ‘SQL Server’, provide the server name, and select parameter in the database as I have captured in the first step then click on ‘Connect’.
 
Select all the tables of this database and then click on ‘Ok’.
 
How To Use Parameters In Power BI
 
Now you can see that your second database will be connected and all tables of this database getting imported in the editor window which is shown in the left pane.
 
How To Use Parameters In Power BI
 

Summary

 
Parameters are a very useful feature of Power BI. Hope you understand how to use the query parameter in the query editor. These were the simple steps to import data from the SQL server using parameters. You can also check the below link for one more use of parameters.
Similarly, you can try to import the data from another type of source with the help of parameters. Thanks for reading.