带有OR关键字的DAX中的多个过滤器

时间:2016-03-22 09:04:17

标签: powerpivot dax ssas-2012 ssas-tabular

我有一个要求,我需要从多个表中评估列,并从我的SSAS表格模型中的Fact表中选择所需的记录。

例如: 从FactA挑选记录,其中:

 ('DimA'[DimA Group] = "Contract" AND'DimB'[DimB Group] = "Contract") OR ('DimA'[DimA Group] = "Commercial", 'DimB'[DimB Group] = "Commercial")

下面是DAX:

MeasureA :=
CALCULATE(SUM('FactA'[Amount Single]),filter(('DimA'[DimA Group] = "Contract", 'DimB'[DimB Group] = "Contract"),
('DimA'[DimA Group] = "Commercial", 'DimB'[DimB Group] = "Commercial"),))

我得到的错误是当前上下文中不支持运算符或表达式'()'。

非常感谢任何帮助

1 个答案:

答案 0 :(得分:1)

试试这个:

MeasureA :=
CALCULATE(
  SUM('FactA'[Amount Single]),
  FILTER(
    CROSSJOIN(VALUES('DimA'[DimA Group]), VALUES('DimB[DimB Group])),
   ('DimA'[DimA Group] = "Contract" && 'DimB'[DimB Group] = "Contract")
   || ('DimA'[DimA Group] = "Commercial" && 'DimB'[DimB Group] = "Commercial")
  )
)

有关此模式的更多信息,请参阅here