Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

DAX syntax

Hi,   I'm trying to SUM a few variables, but I'm not sure how to write this in DAX.   Please take a look at my attached screenshots and you'll see what I am trying to do.  The screenshot with the...
  • PaulDBrown's avatar
    PaulDBrown
    3 years ago

    With this sample table called 'fTable'

     

    Try:

    Sum A | C | D = 
    CALCULATE([Sum Value], FILTER(fTable, fTable[Category] IN {"A", "C", "D"}))

    which delivers the same result as:

    Sum A + C + D = 
    VAR _A = CALCULATE([Sum Value], FILTER(fTable, fTable[Category] = "A"))
    VAR _C = CALCULATE([Sum Value], FILTER(fTable, fTable[Category] = "C"))
    VAR _D = CALCULATE([Sum Value], FILTER(fTable, fTable[Category] = "D"))
    RETURN
    _A + _C + _D