Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreWe've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now
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!
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 9 | |
| 8 | |
| 3 | |
| 2 | |
| 2 |
| User | Count |
|---|---|
| 23 | |
| 14 | |
| 10 | |
| 6 | |
| 5 |