Forum Discussion
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:
| C | D | Column subtotal | % of grand total | |
| A | 2 | 7 | 9 | 53% |
| B | 3 | 5 | 8 | 47% |
| Row subtotal | 5 | 12 | 17 | 100% |
| % of grand total | 29% | 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
- amitchandakSuper User
Anonymous , I have shown an approach in the blog on how can you get an additional row, and see if the same can help in your case
https://amitchandak.medium.com/power-bi-add-grand-total-row-in-the-bar-visual-44c3d1d463be
- v-easonf-msftCommunity 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