Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Summarizing within a VAR expression

Hi all, I'm struggling to find the answer, so hopefully someone here can help me. I feel like it's an easy fix within DAX for a trained eye. πŸ˜‰ This is an example set I had. Store Matrix...
  • smpa01's avatar
    3 years ago

    Anonymous 

    Measure = 
    VAR numerator =
        CALCULATE (
            SUMX (
                ALL ( 'table'[Store] ),
                CALCULATE (
                    SUM ( 'table'[Average Revenue] ),
                    ALLEXCEPT ( 'table', 'table'[Store], 'table'[Matrixcode] )
                )
            )
        )
    VAR denominator =
        CALCULATE (
            DISTINCTCOUNT ( 'table'[Store] ),
            ALLEXCEPT ( 'table', 'table'[Matrixcode] )
        )
    RETURN
        DIVIDE ( numerator, denominator )