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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

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
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.