Forum Discussion
Weighted Average while filtering out another column
I was trying to make a chart from the data as follows with the filter on category = A
| Category | Name | Year | Value | Health | Class | Class 2 |
| A | Celery | 2025 | 14 | 883 | Veg | AB |
| A | Carrot | 2025 | 14.7 | 1,314 | Veg | AB |
| A | Cabbage | 2025 | 8.6484 | 682 | Veg | AC |
| A | Asparagus | 2025 | 19.1529 | 332 | Veg | AC |
| A | Apple | 2025 | 23.85 | 528 | Fruit | AC |
| A | Orange | 2025 | 40.2027 | 544 | Fruit | AD |
| B | Celery | 2025 | 16 | 893 | Veg | AB |
| B | Carrot | 2025 | 16.7 | 1,324 | Veg | AB |
| B | Cabbage | 2025 | 10.6484 | 692 | Veg | AC |
| B | Asparagus | 2025 | 21.1529 | 342 | Veg | AC |
| B | Orange | 2025 | 42.2027 | 554 | Fruit | AD |
A total for Health = 4283
A subtotal Veg = 3211
A subtotal Fruit = 1072
And I need to subtotal the weight using class F and G separately. So far, for column F - Class, it looks like the following:
The following table is also filtered out by Column A
| Row Labels | Sum of Value |
| Fruit | 16.03 |
| Apple | 23.85 |
| Orange | 40.20 |
| Veg | 25.11 |
| Asparagus | 19.15 |
| Cabbage | 8.65 |
| Carrot | 14.70 |
| Celery | 14.00 |
| Grand Total | 120.55 |
Fruit subtotal is calculated as follows: =SUM(23.85+40.2027)*(SUM(528+544)/4283)
Veg subtotal is calculated as follows: =SUM(14+14.7+8.6484)*(SUM(883+1314+682)/4283)
I've tried the following formula, but it doesn't seem to work
Cam calc =
DIVIDE(SUM('Table'[Health])*'Table'[Value],
SUM('Table'[Health])
)
Hi,
PBI file attached.
Hope this helps.
2 Replies
- vicky_Super User
Here's my measure:
Cam calc = DIVIDE( SUM('Table'[ Health ]) * SUM('Table'[Value]), CALCULATE(SUM('Table'[ Health ]), REMOVEFILTERS('Table'[Class])) )and the result (ignore the Sum of Value column):
btw - I can't get the same results as your example (I just filtered by Category = A; why would Asparagus not be included in the Cam calc measure in the veg subtotal? you might need to change the calculate parameter depending on your specific requirements)
- Ashish_MathurSuper User