powerpivotdaxssas-2012ssas-tabular

Multiple filters in DAX with OR Keyword


I have a requirement where I need to evaluate column from multiple tables and select required records from my Fact table in my SSAS tabular Model.

Eg: Pick Records from FactA where:

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

Below is the DAX is have:

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

This error I get is Operator Or Expression '()' is not supported in the current context.

Any help is much appreciated


Solution

  • Try this:

    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")
      )
    )
    

    More on this pattern is described here.