Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
AndyB87
New Member

Measure for matrix visual that rolls up values from child rows to parent rows.

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:

AndyB87_1-1686848801908.png

 

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?

1 REPLY 1
some_bih
Super User
Super User

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





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.