【问题标题】:Dax Measure to show previous monthDax Measure 显示上个月
【发布时间】:2020-06-18 11:49:09
【问题描述】:

我有一个显示如下的表格:

AccountingMonth | AccountingYear | MonthType
January         | 2019           | Other
February        | 2019           | Other
March           | 2019           | Other
April           | 2019           | Other
May             | 2019           | Other
June            | 2019           | Other
July            | 2019           | Other
August          | 2019           | Other
September       | 2019           | Other
October         | 2019           | Other
November        | 2019           | Other
December        | 2019           | Other
January         | 2020           | Other
February        | 2020           | Previous Month
March           | 2020           | Current Month
April           | 2020           | Next Month

我正在尝试创建一个仅选择上个月的度量。如何使用 VALUES 进行过滤?

GaugePreviousMonthTitle =
VAR SelectedValues =
    VALUES ( Budget[AccountingMonth] ) ------filter for MonthType of Previous Year???
RETURN
    SelectedValues

【问题讨论】:

  • 是否有某些原因需要使用 VALUES()?如果我想在您标记的行上显示会计月份,我只需过滤 MonthType 列。
  • 我这样做是为了进行度量计算。

标签: powerbi dax


【解决方案1】:
GaugePreviousMonthTitle =
CALCULATE(
    VALUES ( Budget[AccountingMonth] ), 
    Budget[MonthType]="Pevious Month"
   )

这里的假设是“上个月”标志在表中始终是唯一的,因此将始终只返回一个 AccountingMonth。如果不是这样,您将需要保护结果不返回多个值。

【讨论】:

  • 谢谢!是的,它总是独一无二的,所以这很完美!
猜你喜欢
  • 2021-10-04
  • 1970-01-01
  • 1970-01-01
  • 2020-05-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多