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
EashwarBalaji
Resolver I
Resolver I

Dynamic parameter

Is there a way to dynamically change a parameter value?

I have a parameter "MaxDate" which needs to have yesterday's date.
I have created a table with a single cell that contains yesterday's date that updates everyday, if that helps. 

EashwarBalaji_0-1676371296327.png


But when i add this to the query of parameter, it doesnt automatically update, i have to manually update the current value of the parameter every day.

EashwarBalaji_0-1676370843422.png


Is there any solution to this?
I'm not stuck in stone to use this table, if there is any other way to achieve this dynamic update of parameter, I'm open to that as well (like using the advanced editor or something).

Thanks in advance!

1 ACCEPTED SOLUTION
EashwarBalaji
Resolver I
Resolver I

Instead of using a paramter, I just created a table with a single cell that calculates the yesterday's date using the formula: Date.AddDays(Date.From(DateTime.FixedLocalNow()),-1)

 

I then add this column to my original table, where I was initially using the parameter.
Now that column updates as the above created table updates (everytime i refresh)

View solution in original post

3 REPLIES 3
EashwarBalaji
Resolver I
Resolver I

Instead of using a paramter, I just created a table with a single cell that calculates the yesterday's date using the formula: Date.AddDays(Date.From(DateTime.FixedLocalNow()),-1)

 

I then add this column to my original table, where I was initially using the parameter.
Now that column updates as the above created table updates (everytime i refresh)

MAwwad
Super User
Super User

Yes, you can use Power Query to dynamically update the parameter value. Here's how you can do it:

  1. In Power Query, create a new query that retrieves yesterday's date. You can do this by connecting to your data source and filtering for the date that is one day before today's date.

  2. Add a step that selects the date value from the query. You can do this by selecting the column with yesterday's date, right-clicking on the column, and selecting "Use First Row as Headers".

  3. Rename the column to "MaxDate" to match the parameter name.

  4. Load the query as a connection only, by selecting "Connection Only" from the Load Options.

  5. Go to the parameter settings and change the Default Value to the following expression: = DateTime.LocalNow() - #duration(1,0,0,0)

  6. Save and refresh your report. The parameter should now have yesterday's date as the default value.

This method will ensure that the parameter value is always up to date and does not require manual updates.

Thanks for your response.


I have created the MaxDate column with yesterday's date in the row. But adding the above expression to parameter raises the following error:

 

EashwarBalaji_0-1676376430938.png

 Can you help me sort this please?

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.