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
I have several sql queries that need to delare a date, e.g. Declare @date1 datetime ='31july2020'
Instead of changing the date for all the queries each month, I want to link it to another query "Date" so that every month I only need to update the date in the "Date" query, then all other queries' date will be updated. Thanks!
Solved! Go to Solution.
Hi @qazwsxedc ,
If you import data by T-SQL, you could reference this similar threads to use parameters change date.
https://community.powerbi.com/t5/Desktop/How-do-I-pass-parameters-to-my-SQL-statement/td-p/118716
https://community.powerbi.com/t5/Desktop/Declare-parameters-for-SQL-query-in-Power-BI/td-p/195620
Hi @qazwsxedc ,
If you import data by T-SQL, you could reference this similar threads to use parameters change date.
https://community.powerbi.com/t5/Desktop/How-do-I-pass-parameters-to-my-SQL-statement/td-p/118716
https://community.powerbi.com/t5/Desktop/Declare-parameters-for-SQL-query-in-Power-BI/td-p/195620
Thank you very mcuh. The links are useful!
@qazwsxedc
Create a Parameter in Power Query and refer that in all other queries. You can change the Parameter at any time.
________________________
If my answer was helpful, please consider Accept it as the solution to help the other members find it
Click on the Thumbs-Up icon if you like this reply 🙂
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
Thanks! I have created the Parameter named "Date", but how to insert the parameter and repplace the '31July2020' in "Declare @date1 datetime ='31july2020'"?
I thought you wanted to replace the static date with a parameter in your Power Query query.
It seems you wanted to do it prior to bring the data into Power Query. However, once you connected, go to advanced editor, replace the date with parameter.
Share your query if you need any help on that
________________________
If my answer was helpful, please consider Accept it as the solution to help the other members find it
Click on the Thumbs-Up icon if you like this reply 🙂
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 19 | |
| 10 | |
| 9 | |
| 7 | |
| 6 |