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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
PowerUser123
Helper II
Helper II

Measure to use different denominator at different level in hierarchy

So my data is structured somewhat like this:

 

PowerUser123_0-1647600527071.png

I have cost at the more granular Product level, but units are at the higher Category level. I would like to create a measure that divides cost by units.

 

In a matrix for January 2021, the measure should return 0.3 when looking at the higher Beauty Category - (20+10)/100. But when I drill-down, I'd like to see 0.1 for Hair - 10/100 and 0.2 for Clothing 20/100.

 

My measure is currently as follows:

 

CPU Measure = DIVIDE(SUMX('CPU',[Cost]),SUMX('CPU',[Unit]),0)

 

So the denominator should be as follows:

 

When Looking at all of 2021 by Category - 150 (100+50)

When looing at Jan 2021 by Category      - 100

When looking at Feb 2021 by Category    - 50

When looking at Jan 2021 by Product       - 100

When looking at Feb 2021 by Product      - 50 

1 ACCEPTED SOLUTION
PaulDBrown
Community Champion
Community Champion

See if this works. I've set up the model with dimension tables as follows:
Result.jpg

and with these measures:

 

Sum Cost = 
SUM('Table'[Cost])
Sum Units = 
SUM('Table'[Unit])
Cost by Unit =
VAR _Ave =
    AVERAGE ( 'Table'[Unit] )
RETURN
    SWITCH (
        TRUE (),
        ISINSCOPE ( DProduct[Product] ), DIVIDE ( [Sum Cost], [Sum Units] ),
        ISINSCOPE ( DCategory[Category] ), DIVIDE ( [Sum Cost], _Ave )
    )

 

To get

Result.jpg

This assumes you are using the average of units per category. If you need a different criteria, you will need to change the calculation in th VAR _Ave

I've attached the sample PBIX file





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






View solution in original post

2 REPLIES 2
PaulDBrown
Community Champion
Community Champion

See if this works. I've set up the model with dimension tables as follows:
Result.jpg

and with these measures:

 

Sum Cost = 
SUM('Table'[Cost])
Sum Units = 
SUM('Table'[Unit])
Cost by Unit =
VAR _Ave =
    AVERAGE ( 'Table'[Unit] )
RETURN
    SWITCH (
        TRUE (),
        ISINSCOPE ( DProduct[Product] ), DIVIDE ( [Sum Cost], [Sum Units] ),
        ISINSCOPE ( DCategory[Category] ), DIVIDE ( [Sum Cost], _Ave )
    )

 

To get

Result.jpg

This assumes you are using the average of units per category. If you need a different criteria, you will need to change the calculation in th VAR _Ave

I've attached the sample PBIX file





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






amitchandak
Super User
Super User

@PowerUser123 , try like

 


CPU Measure = DIVIDE(SUM('CPU'[Cost]),calculate(SUM('CPU'[Cost]), allexcept('CPU', 'CPU'[Category])))

 

or


CPU Measure = DIVIDE(SUM('CPU'[Cost]),calculate(SUM('CPU'[Cost]), filter(allselected('CPU'), 'CPU'[Category] = max('CPU'[Category]) )))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors