Showing results for 
Search instead for 
Did you mean: 
New Member

Set parameter = DateTime.LocalNow()



Is there any way to set a parameter as a function? I want to set a parameter as today like this: DateTime.LocalNow().

As a default I want it to be today's date but I also want to be able to set the date manually if I want to see data from a certain date in my dashboards.


Thank you!


New Member

Create your paramenter and then right click it on the right under your queries and select 'Advanced Editor'.  You can then put in a function.  In my case, I needed it as text so I used the following-


Source = let
Source1 = DateTime.ToText(DateTime.LocalNow())

meta [IsParameterQuery=true, Type="Text", IsParameterQueryRequired=true]

But...with this the parameter is transformed into a query?

Helper II
Helper II

Any updates on this topic?

Frequent Visitor

Hi you all M Gurus out there...

Has anyone managed to pass a DateTime.LocalNow() value as a parameter default ?

I'm trying it right now with the latest version of PBI Desktop but it seems the value is still interpreted as a String in the parameter editor.

Any clues ?



Community Champion
Community Champion

That is currently not possible. Parameters only allow values with List of Values, Any Values or other Query as the suggested values. if you have only one value that is defined using DateTime.LocalNow() then you can use that value as a suggested values using Query Option in the parameters dialog box. However, You can use the list of values as the suggested values where you have to manually select the today's date to pass the parameter's value. It is not dynamic but with the parameters in the baby stage, it would be more convenient option.

Thanks & Regards,

Love the Self Service BI.
Please use the 'Mark as answer' link to mark a post that answers your question. If you find a reply helpful, please remember to give Kudos.

Want to revive this thread... is this still possible in the latest PowerBI version?

I'm trying to do this now as well. I think it must be possible

Trying to figure out the same issue... 

Helpful resources

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

charticulator_carousel_with_text (1).png

Charticulator Design Challenge

Put your data visualization and design skills to the test! This exciting challenge is happening now through May 31st!

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Power BI Release May 2022 768x460.png

Check it out!

Click here to read more about the May 2022 updates!