This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. We're covering it all. You won't want to miss it.
Learn moreLevel up your Power BI skills this month - build one visual each week and tell better stories with data! Get started
Dear Forum,
in PowerBI through a ODBC connection i am connecting to a mySql db and the following is my sql query instruction.
What i want is pass parameteres to this sql instruction instead of hardcoding the dates.
Is it possible to do this?
Thank you a lot
Solved! Go to Solution.
Hi @powerbricco,
You can achieve this by using Power Query parameters and incorporating them into your native SQL statement, allowing filtering to occur directly in MySQL rather than within Power BI. This method ensures only the necessary data is retrieved from the source, helping to prevent performance issues that can arise from filtering after import.
To set this up, create parameters in Power BI Desktop by navigating to Transform Data -> Manage Parameters -> New Parameter. For example, you might create StartDate and EndDate parameters with a data type of Date or Date/Time. These will serve as dynamic inputs for your query.
Next, open the Advanced Editor for your ODBC query and update the SQL string to reference these parameters. In Power Query (M), you can insert the parameter values into the SQL statement and format them appropriately for MySQL. When the query runs, Power BI rebuilds the SQL with the current parameter values and sends it to the database.
This approach applies the date filter at the source, so MySQL returns only the relevant data, resulting in faster refresh times and avoiding unnecessary data loads. It is effective for refresh-time filtering in Import mode. For end-user runtime parameters in Power BI Service, DirectQuery or a stored procedure would be required, but for refresh scenarios, this method is recommended.
Thank you.
Hi @powerbricco,
You can achieve this by using Power Query parameters and incorporating them into your native SQL statement, allowing filtering to occur directly in MySQL rather than within Power BI. This method ensures only the necessary data is retrieved from the source, helping to prevent performance issues that can arise from filtering after import.
To set this up, create parameters in Power BI Desktop by navigating to Transform Data -> Manage Parameters -> New Parameter. For example, you might create StartDate and EndDate parameters with a data type of Date or Date/Time. These will serve as dynamic inputs for your query.
Next, open the Advanced Editor for your ODBC query and update the SQL string to reference these parameters. In Power Query (M), you can insert the parameter values into the SQL statement and format them appropriately for MySQL. When the query runs, Power BI rebuilds the SQL with the current parameter values and sends it to the database.
This approach applies the date filter at the source, so MySQL returns only the relevant data, resulting in faster refresh times and avoiding unnecessary data loads. It is effective for refresh-time filtering in Import mode. For end-user runtime parameters in Power BI Service, DirectQuery or a stored procedure would be required, but for refresh scenarios, this method is recommended.
Thank you.
Dear @rohit1991, applying filters after import is terribly slowing the whole process.
You were saying it is possible to use Power Query parameters and reference them in the SQL statement. How is this possible?
Thanks for your help
Hii @powerbricco
The supported approach is to use Power Query parameters and reference them in the SQL statement (or apply filters after import). For true runtime parameterized queries, you must use DirectQuery with supported connectors or handle parameters via stored procedures (where supported).
Check out the April 2026 Power BI update to learn about new features.
Sign up to receive a private message when registration opens and key events begin.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
| User | Count |
|---|---|
| 36 | |
| 33 | |
| 31 | |
| 24 | |
| 18 |
| User | Count |
|---|---|
| 66 | |
| 50 | |
| 33 | |
| 24 | |
| 24 |