This is best Fabric, Power BI, SQL and AI community event. How do we know? The last event sold out! Save €200 with code FABCMTY200.
Register nowA new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.
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.
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 |
|---|---|
| 33 | |
| 26 | |
| 21 | |
| 20 | |
| 15 |
| User | Count |
|---|---|
| 63 | |
| 44 | |
| 28 | |
| 24 | |
| 22 |