如何获取Power Bi当前月份

时间:2019-04-15 14:58:34

标签: powerbi powerquery

我正在尝试通过此查询在power bi中添加自定义列:

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

但结果是:

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

那我怎么得到当前月份?

2 个答案:

答案 0 :(得分:1)

您需要的功能是DateTime.LocalNow

因此您的查询步骤变为:

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

答案 1 :(得分:0)

您还可以创建一列

enter image description here

然后执行以下操作:

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