Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
I'm trying to write a measure for a matrix visualization that will roll up a calculation of a percentage from child rows to parent rows.
I have a data model with a fact table called 'retailSales' that contains transaction data and a dimension table called 'product' that contains product information. Our products are divided into a taxonomy of categories, so the product table has fields for [masterCategory], [category], and [subcategory]. I'm putting together an analysis of our product categories. I have a matrix where the rows drill down from master category to category to subcategory. I have a column that calculates dollar sales for each row. I'd like to write a measure that calculates each row's dollar sales value as a % of its parent row subtotal (and % of total sales for each master category). It should look like the following example:
So far, I have a measure that successfully calculates each row's % share of total sales, but it doesn't roll up percentages from child rows to parent rows the way I want. It calculates a child row as a % of the total rather than its parent. It looks like this:
CategoryShare =
DIVIDE(
SUM( retailSales[soldPrice] ),
CALCULATE(
SUM( retailSales[soldPrice] ),
ALLSELECTED( product )
)
)
Any thoughts on how to write a measure that does what I'm looking for?
Hi @AndyB87 try to use ALLEXCEPT for your column (I guess [category],) as shown in example https://www.sqlbi.com/articles/using-allexcept-versus-all-and-values/ I hope this help
Proud to be a Super User!
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 19 | |
| 13 | |
| 9 | |
| 4 | |
| 4 |
| User | Count |
|---|---|
| 30 | |
| 26 | |
| 17 | |
| 11 | |
| 10 |