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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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]) )))

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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