heyYou
heyYou

Reputation: 13

Define today's date in power bi

I have a use case report on Power Bi for 2018-2019. I used many date functions as isInCurrentYear, isInCurrentMonth...

But today's date always change (normal)... So I would like to fix it.

For example, I would like that the today date is 30/03/2019. And never change.

How can I do that? Thanks

Upvotes: 0

Views: 7727

Answers (1)

Jon
Jon

Reputation: 4967

To define today's date it will be: DAX: TODAY() M: DateTime.LocalNow() or DateTime.FixedLocalNow()

For M just to get the date part use DateTime.Date(DateTime.LocalNow())

You can then format or extract the relevant part of the date using DateTime.Date(DateTime.LocalNow()) , and use an IF clause to check if it todays date

In M calculated colum

if [Your date column] = DateTime.Date(DateTime.LocalNow()) then "Current Date" else "Not Current Day

You can set a fixed date using Date.FromText() for example:

Date.FromText("2010-12-31")

You can also set a date using a parameter, and reference that in the query

Hope that helps

Upvotes: 1

Related Questions