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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
ashukla2
Regular Visitor

Connect slicer value to Advanced Editor for SQL query

I am creating a dashboard that is connected to a SQL database. There are several different filters which the user can filter on and the existing tables in the database will be filtered and displayed. 

 

I want to also generate a SQL query from the dashboard and display the resulting table. I am able to write the query I want in the Advanced Editor which makes a new table and display the information. However, within the SQL query I want certain values to be passed based on the current value in the slicer. Is this possible? If so how should I go about doing this?

 

I am also open to using other input forms besides a slicer. Due to the size of the data, I cannot do a JOIN query and then use the slicer to filter the data. I want to do a JOIN query with a WHERE clause and pass the slicer values into the WHERE clause. An example is below:

 

SELECT table1.col2, table1.col3, table2.col3

FROM table1

LEFT JOIN table2 ON table1.col1 = table2.col1

WHERE table1.col2 = <VALUE FROM SLICER> AND table1.col4 = <VALUE FROM DIFFERENT SLICER>

 

Appreciate any insights on this, thanks!

1 ACCEPTED SOLUTION
danextian
Super User
Super User

Hi @ashukla2,

 

You can affect the SQL query using parameters which in turn affects the data model and the visuals but is not the other way around. Slicer values cannot be passed on to a SQL query. What you can do is load the data with all the needed rows and use the values from those columns in a slicer/s.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

2 REPLIES 2
danextian
Super User
Super User

Hi @ashukla2,

 

You can affect the SQL query using parameters which in turn affects the data model and the visuals but is not the other way around. Slicer values cannot be passed on to a SQL query. What you can do is load the data with all the needed rows and use the values from those columns in a slicer/s.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
Rabech
Frequent Visitor

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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