Forum Discussion
Filter-weighted average
- 3 years ago
Hi Anonymous
Sorry for the late reply. You can create a measure with below DAX to get the weighted average indicator.
New Indicator = VAR _table = ADDCOLUMNS ( ADDCOLUMNS ( SELECTCOLUMNS ( 'Table', "Quantity", 'Table'[Quantity], "Indicator", 'Table'[Indicator] ), "Percentage of quantity", DIVIDE ( [Quantity], SUM ( [Quantity] ) ) ), "Apportionment", [Percentage of quantity] * [Indicator] ) RETURN SUMX ( _table, [Apportionment] )Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.
Hi Anonymous
Thank you for providing the sample data. It is very helpful. However currently I don't understand what the expected result should be like. Can you explain how to weight and filter with some examples? For example, in 2018, Wine cellar 102 is repeated, how do you want to deal with it?
Best Regards,
Community Support Team _ Jing
| Year | Center | Wine cellar | Quantity | Indicator | Percentage of quantity | Apportionment |
| 2018 | Rabudos | 102 | 42947 | 3,6 | 77% | 2,75954808 |
| 2018 | Rabudos | 102 | 13080 | 2,4 | 23% | 0,56030128 |
| 56027 | 3,32 |
- v-jingzhang3 years agoCommunity Support
Hi Anonymous
Sorry for the late reply. You can create a measure with below DAX to get the weighted average indicator.
New Indicator = VAR _table = ADDCOLUMNS ( ADDCOLUMNS ( SELECTCOLUMNS ( 'Table', "Quantity", 'Table'[Quantity], "Indicator", 'Table'[Indicator] ), "Percentage of quantity", DIVIDE ( [Quantity], SUM ( [Quantity] ) ) ), "Apportionment", [Percentage of quantity] * [Indicator] ) RETURN SUMX ( _table, [Apportionment] )Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.- Anonymous3 years agoNot applicable
Thank you very much, it was perfect