Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
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?
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
how are you defining the parameter value? is it coming from the result of another query, or is it static?
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
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
33 | |
21 | |
20 | |
13 | |
12 |
User | Count |
---|---|
27 | |
18 | |
17 | |
16 | |
14 |