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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Anonymous
Not applicable

Dataset date as parameter

Hi

 

Im trying to add a parameter for narrowing a a dataset.

 

= Sql.Database("xxxserver.database.windows.net", "DB", [Query="Declare @DateLoadFromMonthMinus1 as Date;
Declare @DateLoadFromYearMinus10 as Date;
set @DateLoadFromMonthMinus1=DATEADD(MONTH,-1,GETDATE());
set @DateLoadFromYearMinus10=DATEADD(YEAR,-10,GETDATE());
select * from [schema].[table] where THE_DATE > " & paramDateLoadFrom & ""])

 

The PowerBI parameter paramDateLoadFrom is text.

 

The reason why I try to do this is to reduce the imported dataset so its possible to soucecontrol the pbix file since we are using imported mode

Is this approch not valid? 

 

3 REPLIES 3
v-deddai1-msft
Community Support
Community Support

Hi @Anonymous ,

 

Would you please try the following m query:

 

 

= Sql.Database("xxxserver.database.windows.net", "DB", [Query="Declare @DateLoadFromMonthMinus1 as Date;
Declare @DateLoadFromYearMinus10 as Date;
set @DateLoadFromMonthMinus1= Date.AddMonths(DateTime.Date(DateTime.LocalNow()),-1);
set @DateLoadFromYearMinus10=Date.AddYears(DateTime.Date(DateTime.LocalNow()),-10);
select * from [schema].[table] where THE_DATE > " & paramDateLoadFrom & ""])

 

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Best Regards,

Dedmon Dai

lbendlin
Super User
Super User

how are you defining the parameter value? is it coming from the result of another query, or is it static?

Anonymous
Not applicable

I set the parameter on the dataset in the service to "@DateLoadFromYearMinus10". The scheduled refresh succeeds but its not using the expected parameter. Its seem like it using the other defined parameter from the example which is the default parameter

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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