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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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.










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


Proud to be a Super User!









"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.










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


Proud to be a Super User!









"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
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.