Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

custom aggregation in matrix not working

I have a matrix with 3 levels:   I have a custom aggregation, working fine, the dax code is:                 FixedCosts = SUM('Table'[FCosts]) VariableCosts = SUM('Table'[VCosts])  ...
  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi Anonymous ,

     

    According to your description, here are my steps you can follow as a solution.

    (1) This is my test data.

    (2) We can create a calculated column.

     

    Column = 
    VAR _level2 =
        CALCULATE (
            SUM ( 'Table'[value] ),
            ALLEXCEPT ( 'Table','Table'[level2] )
        )
    RETURN
        IF ( _level2 > 0, 0, _level2 )
    

     

    (3)Then we can create a measure.

     

    Measure = 
    SWITCH (
        TRUE (),
        ISINSCOPE ( 'Table'[level3]), SUM ('Table'[value] ),
        SUM ( 'Table'[Column] )
    )
    

     

    (4) Then the result is as follows.

     

    Best Regards,

    Neeko Tang

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.