Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hello,
How can I use a Parameter (StartYear) in this SQL Statement in Power BI?
Hello,
Yes but what about adding a parameter for the Start Year to load data?
Michael
Hi @mikebi ,
Thanks for the reply from adudani , please allow me to provide another insight:
When writing your SQL query within Power BI, you cannot directly embed Power BI parameters into the SQL code.
You can use Power Query Editor to dynamically generate your SQL query string based on the parameter value.
In Power Query Editor, select Advanced Editor.
Enter content similar to the following in the page that opens.
let
ParameterHere = Number.ToText( #"StartYear Parameter"[Value] ),
SqlQuery = "SELECT * FROM YourTable WHERE Year >= " & ParameterHere,
Source = Sql.Database("YourServer", "YourDatabase", [Query=SqlQuery])
in
Source
Replace "YourTable", "YourServer", and "YourDatabase" with your actual table name, server, and database names.
Just refresh it after setting it up.
If you have any further questions please feel free to contact me.
Best Regards,
Yang
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
hi @mikebi ,
reference this: Making data source parameters easy in Power BI Desktop (youtube.com)
let me know if this resolves the issue.
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 39 | |
| 37 | |
| 33 | |
| 32 | |
| 29 |
| User | Count |
|---|---|
| 132 | |
| 86 | |
| 85 | |
| 68 | |
| 64 |