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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
nleuck
Post Patron
Post Patron

Stored Procedures and setting dynamic dates

Does anyone know of a way to set the End Date dynamically? I have a Start Date parameter and End Date parameter. When you Import the SP into Power BI there is the SQL Statement in Advance Options. I tried setting the End Date parameter with some different dynamic SQL statements but it didn't work. I need to refresh this data every month so if I set the End Date to a specific date then try to refresh nothing will happen. I kept getting an error that Power BI couldn't accept my SQL code for End Date. Has anyone ever tried to do this before?

 

Any help would be greatly appreciated!

 

Thanks,

4 REPLIES 4
v-danhe-msft
Employee
Employee

Hi @nleuck,

Based on my research, you could refer to below link about how to pass parameters to SQL in Power BI:

https://community.powerbi.com/t5/Desktop/How-do-I-pass-parameters-to-my-SQL-statement/td-p/118716

https://blog.crossjoin.co.uk/2016/12/11/passing-parameters-to-sql-queries-with-value-nativequery-in-...

 

Regards,

Daniel He

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hello @v-danhe-msft,

 

I don't want to enter the dates. I want to be able to hit refresh on Power BI desktop and the new data be there. The problem is I can't find a way to bring in the End Date dynamically like you would in Reporting Services. So every month when the report runs the new data is there. In SSRS the report populates with the new month's data and my users do not have to select a date range. I just need to find a way in Power BI to bring in my End Date the same way.

 

 

Greg_Deckler
Super User
Super User

Can you share your SQL code?


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

For End Date I'm using:

 

SET EndDate AS DATE = EOMONTH(GETDATE(), -1)

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors