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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
BalaVenuGopal
Resolver I
Resolver I

Passing parameter to sql from dropdown list in powerBI (Very interesting and challenging)

Dear All,

My requiremnt is to send parameter to sql but i need drop down to choose valeu

Table Info : Assume I have tabel(Emp_Info) with columns [EmpName,Location,salary]
Requiremnt : My table have 2 crore rows
    I want to give user an option to choose location (Which shoud be dropdown list and it should auto populate from the existng  table)
    when user select any location this parameter should pass to sql database and should only data related to Selected Location.
   
Please help me this approach.

My Experiments :step 1 - Created Source 1 with sql table (select * from my Emp_Info)
    step 2 - Creted source 2 with sql select distinct Location from emp_info
    step 3 - Create new parameter(Location_param) and choose query and (choosen source 2)
    step 4 - Opened advanced editor and modified select * from my Emp_Info where location = '"&Location_param&"'
    
    But while applying changes am gettig error Please suggest solution

4 REPLIES 4
Anonymous
Not applicable

It turns out that this is actually possible in Power BI. I've created a walkthrough video on how to do this here.

 

The basic gist is to add an R visual that takes in your slicer selection as its value. There is an R package called RODBC that can run SQL code against your database. You can then pass your slicer value into the SQl query using some string interpolation or the "paste" function. Let me know how this works for you.

 

Thanks,

Parker

v-chuncz-msft
Community Support
Community Support

@BalaVenuGopal,

 

Make sure you use the Import mode and set parameter Type to Text. For DirectQuery mode, use a Slicer instead.

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-chuncz-msft

Thank you for your reply. Could you plese explain in detailed , I am planing to load data from sql to powerbi data model with filter but slicers will appear at report level correct so how can i make use of slicers here

@BalaVenuGopal,

 

Just drag [location] to Field.

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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