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

July 28 - August 9 | Final Round of the Power BI Dataviz World Championships. This is your chance. Learn more

Reply
Anonymous
Not applicable

Create dynamic SQL server query

Hi Power BI Community,

 

I need your support with suggestions on how to create an SQL Query that can change dynamically based on selected options from the user. I found a guide that discusses this titled: Dynamic M Query Parameters in Power BI Desktop - Learn | Power BI, but the guide appears to be irrelevant since I cannot find the "bind to parameter" field in my Model view section.

 

What I need to do is receive a different set of values populated on my visuals based on a slicer. The slicer holds terms such as 2022/23, 2023/24 ... And by selecting one of the options, data in the query should be updated with records that match the selected term. How can I achieve this?

 

Thanks in advance for your support.

 

Cheers.

Screenshot 2024-03-08 113523.png

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

since I cannot find the "bind to parameter" field in my Model view section

Your data source needs to be in Direct Query Mode.  You need to have prepared a parameter for your query.  Then the "Bind"  option will be visible when you select the column to bind to and expand the Advanced section.

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @Anonymous ,

 

@lbendlin  provided a great idea for the solution, the dynamic M query parameter gives the model author more control over the selection of filters to be incorporated into the DirectQuery source query. For more detailed information about query parameters and power bi templates, please refer to the documentation: Deep Dive into Query Parameters and Power BI Templates | Microsoft Power BI Blog | Microsoft Power B....

 

In addition, you can also use dax logic to generate a dynamic power bi slicer. For specific operation steps, please refer to the document: Dynamic Power BI Slicer Using DAX Logic (mssqltips.com).

 

If your Current Period does not refer to this, please clarify in a follow-up reply.

 

Best Regards,

Clara Gong

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

lbendlin
Super User
Super User

since I cannot find the "bind to parameter" field in my Model view section

Your data source needs to be in Direct Query Mode.  You need to have prepared a parameter for your query.  Then the "Bind"  option will be visible when you select the column to bind to and expand the Advanced section.

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

Fabric Community Sticker Design Challenge Barcelona Carousel

Fabric Community Sticker Challenge - Barcelona 2026

If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!

July Power BI Update Carousel

Power BI Monthly Update - July 2026

Check out the July 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors