Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

One Measure With Different Calculations Depending on Matrix Row Group Value

Hi everyone,   I need to add three extra categories or groups at the bottom of a matrix and do a different calculation for them. For example, let's say I have a matrix with one category/group "Car...
  • sturlaws's avatar
    6 years ago

    Hi Anonymous 

     

    I am a bit confused by your naming of your table, so I created this sample report with some moclup data: pbix 

    I have written the measure like

    measure = 
    VAR _sv =
        CALCULATE ( SELECTEDVALUE ( MatrixRows[MatrixRows] ) )
    RETURN
        SWITCH (
            TRUE ();
            _sv = "Total"; CALCULATE ( COUNTROWS ( cars ); ALL ( Cars ) );
            _sv = "Average"; CALCULATE(AVERAGEX ( VALUES ( Cars[CarName] ); CALCULATE(COUNTROWS ( Cars ) ));ALL(Cars));
            _sv = "Other"; BLANK ();
            COUNTROWS ( Cars )
        )

     

    Cheers,
    Sturla

    If this post helps, then please consider Accepting it as the solution. Kudos are nice too.