TheGeeky
TheGeeky

Reputation: 971

How to get current month in power bi

I'm trying to add a custom column in power bi by this query:

= Table.AddColumn(#"Filtered Rows", "IsCurrentMonth",  if(Date.Month([Timestamp])=Date.Month(NOW())) then "Current Month" else "Other")

but the result is:

Expression.Error: The name 'NOW' wasn't recognized.  Make sure it's spelled correctly.

so how can I get the current month?

Upvotes: 1

Views: 20159

Answers (2)

ainsighta
ainsighta

Reputation: 98

You could also create a column

enter image description here

and do this:

Column = if(MONTH('Date'[Date])=Month(NOW()), "Current Month", "Other")

Upvotes: 0

Olly
Olly

Reputation: 7891

The function you need is DateTime.LocalNow

So your query step becomes:

= Table.AddColumn(#"Filtered Rows", "IsCurrentMonth",  if(Date.Month([Timestamp])=Date.Month(DateTime.LocalNow())) then "Current Month" else "Other")

Upvotes: 1

Related Questions