Forum Discussion
missing subtotal for running total in matrix
I have the following matrix and table, the subotal is missing in the running totals where the category is empty.
| Category | Sub Category | Sub Category 2 | Amount | Date |
| 1 | 1.1 | 1.1.1 | 1 | 01/01/20 |
| 1 | 1.2 | 1.2.1 | 1 | 01/02/20 |
| 1 | 1.3 | 1.3.1 | 1 | 01/03/20 |
| 1 | 1.1 | 1.1.2 | 1 | 01/04/20 |
| 1 | 1.2 | 1.2.2 | 1 | 01/05/20 |
| 1 | 1.3 | 1.3.2 | 1 | 01/06/20 |
| 2 | 2.1 | 2.1.1 | 1 | 01/06/20 |
| 2 | 2.1 | 2.1.2 | 1 | 01/05/20 |
| 2 | 2.2 | 2.2.2 | 1 | 01/04/20 |
| 2 | 2.2 | 2.2.1 | 1 | 01/03/20 |
| 2 | 2.3 | 2.3.1 | 1 | 01/02/20 |
I used quick measure for running total -
I think this has to do with the structure of the data, what I did was this:
- A new column has been created that joins the category - subcategory - Subcategory2
ID_CAT = 'Table'[Category]&'Table'[Sub Category]&'Table'[Sub Category 2]- A new table has been created with the categories
IDCAT = SUMMARIZE('Table';' Table'[Category];' Table'[Sub Category];' Table'[Sub Category 2];' Table'[ID_CAT])Now create the following measure:
Total Value = CALCULATE(sum('Table'[Amount]); FILTER(ALLSELECTED(IDCAT[Category]);IDCAT[Category]<= MAX(IDCAT[Category])))Result below and in attach PBIX file.
6 Replies
- MFelix
Super User
Hi mahendi ,
The calculation you have is correct based on the matrix setup and the measure.
In your measure you are picking all the values that are On or After your Maximum category value, looking at the image you have for category 1 subtotal the value 1 for category 2 there is no value so the Sub Total value for that category is blank and it cannot be 1.
Believe you are looking at the sub total at a different way, I have made some changes to the setup of the matrix and renamed the totals:
Has you can see the lines that refer to subcategory is blanks.
- MFelix
Super User
I think this has to do with the structure of the data, what I did was this:
- A new column has been created that joins the category - subcategory - Subcategory2
ID_CAT = 'Table'[Category]&'Table'[Sub Category]&'Table'[Sub Category 2]- A new table has been created with the categories
IDCAT = SUMMARIZE('Table';' Table'[Category];' Table'[Sub Category];' Table'[Sub Category 2];' Table'[ID_CAT])Now create the following measure:
Total Value = CALCULATE(sum('Table'[Amount]); FILTER(ALLSELECTED(IDCAT[Category]);IDCAT[Category]<= MAX(IDCAT[Category])))Result below and in attach PBIX file.