Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Row subtotal in a matrix

Hi,

 

is there a way to get the percent of row subtotals in a matrix? I'd like to obtain the row in red in the following print screen:

Ex:

 

 CDColumn subtotal% of grand total
A27953%
B35847%
Row subtotal51217100%
% of grand total29%71%100% 

 

Thanks in advance

  • Hi, Anonymous 

    If C and D are column names in a table, you can try adding a new table as follows and put the new fields 'Row' to the rows of martix.

    Then you can add custom mesures to display the values in Matrix.

    For example:

    C = 
    VAR _total =
        CALCULATE ( SUM ( 'Table'[C] ), ALLSELECTED ( 'Table' ) )
            + CALCULATE ( SUM ( 'Table'[D] ), ALLSELECTED ( 'Table' ) )
    VAR _rowsubtotal =
        CALCULATE ( SUM ( 'Table'[C] ), ALLSELECTED ( 'Table' ) )
    VAR _percent =
        FORMAT ( _rowsubtotal / _total, "percent" )
    RETURN
        SWITCH (
            SELECTEDVALUE ( 'Row Table'[Row] ),
            "Row subtotal", FORMAT ( CALCULATE ( SUM ( 'Table'[C] ), ALLSELECTED( 'Table' )), "General Number" ),
            "% of grand total", _percent,
            FORMAT ( SUM ( 'Table'[C] ), "General Number" )
        )

     

    Best Regards,
    Community Support Team _ Eason

2 Replies

  • v-easonf-msft's avatar
    v-easonf-msft
    Community Support

    Hi, Anonymous 

    If C and D are column names in a table, you can try adding a new table as follows and put the new fields 'Row' to the rows of martix.

    Then you can add custom mesures to display the values in Matrix.

    For example:

    C = 
    VAR _total =
        CALCULATE ( SUM ( 'Table'[C] ), ALLSELECTED ( 'Table' ) )
            + CALCULATE ( SUM ( 'Table'[D] ), ALLSELECTED ( 'Table' ) )
    VAR _rowsubtotal =
        CALCULATE ( SUM ( 'Table'[C] ), ALLSELECTED ( 'Table' ) )
    VAR _percent =
        FORMAT ( _rowsubtotal / _total, "percent" )
    RETURN
        SWITCH (
            SELECTEDVALUE ( 'Row Table'[Row] ),
            "Row subtotal", FORMAT ( CALCULATE ( SUM ( 'Table'[C] ), ALLSELECTED( 'Table' )), "General Number" ),
            "% of grand total", _percent,
            FORMAT ( SUM ( 'Table'[C] ), "General Number" )
        )

     

    Best Regards,
    Community Support Team _ Eason