cancel
Showing results for
Did you mean:

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Frequent Visitor

## Measure calculation for subtotal based on sub-hierarchy grouping on condition

I  have a column of data that counts orders by employee, and another that counts if the order has been completed. I created a measure that calculates the completion rate and dropped all this in a matrix which accurately calculates for each level in the org hierarchy (employee, leader, 2nd level, department, etc). Data is dynamic based on the selected dates in the slicer.

I want another measure that calculates the % of teams that are at or above a specific completion rate goal in the same matrix. At the employee level it would just be blank, but the next level up would calculate based on each individual employee >= goal / total employees in that grouping. How do you get the DAX to calculate the condition for each item within the current grouping?

PB Desktop January 2022 is the current version I'm allowed to work in. Below is a simplistic illustration of what I'm trying to accomplish (but I'd be doing that for 6 levels of hierarchy). In excel I would probably use SUMPRODUCT, but in DAX/PBI to count the number of teams it might be a combination of ISINSCOPE and some sort of count unique, then do the same thing adding on the conditional calculation.

 ORG LEVEL ITEMS COMPLETED Complete rate (comp/items) teams at >= 50% %of teams >= 50% Department 38 16 42% 3 =3 / 5 employees in dept Leader 1A 13 7 53% 2 =2 / 2 employees in team Emp 11A 10 5 50% group row1 Emp 21A 3 2 66% group row1 Leader 2A 5 1 20% 0 =0 / 1 employee in team Emp 12A 5 1 20% group row2 Leader 3A 20 8 40% 1 =1 / 2 employees in team Emp 13A 15 5 33% group row3 Emp 23A 5 3 60% group row3

1 ACCEPTED SOLUTION
Community Support

Hi, @Brian_Hunt ;

You could create measures as follow:

``teams at >50% = CALCULATE(COUNT('Table'[Level3]),FILTER('Table',[Complete rate]>=0.5))``
``````of teams >50% =
IF(ISINSCOPE('Table'[Level3]),BLANK(),
[teams at >50%]/COUNT('Table'[Level3]))``````

The final show:

Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

6 REPLIES 6
Community Support

Hi, @Brian_Hunt ;

You could create measures as follow:

``teams at >50% = CALCULATE(COUNT('Table'[Level3]),FILTER('Table',[Complete rate]>=0.5))``
``````of teams >50% =
IF(ISINSCOPE('Table'[Level3]),BLANK(),
[teams at >50%]/COUNT('Table'[Level3]))``````

The final show:

Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Solution Specialist

Hi

I think

measure

%team =
var   count_employee = DISTINCTCOUNT (employee)
var   count_employee>50% =   CALCULATE ( COUNTROW(SUMMARIZE (date,employee)), COMPLETE rate >=50%)
var  group/department = SELECTEDVALUE (employee)

return

if ( group/department <> blank (), blank (), count_employee>50% / count_employee)

Frequent Visitor

This is a huge step towards what I'm trying to accomplish. I was getting a DAX error " A function 'PLACEHOLDER' has been used..." and had to switch the 2nd var to add FILTER to the CALCULATE in order to use the aformentioned measure:

CALCULATE ( COUNTROWS(SUMMARIZE (date,employee)),FILTER(table1,CompleteRate >= 50%)

Unfortunately the percentages were not what I was expecting. I then used SUMMARIZE to create a table to see what it was actually doing, and broke otu the distinct count, and row count >50% to compare data. I managed to the get whole number counts of distinct employee and employee > 50 to add up, but the [>50] / [distinct count] was Summing the individual row percentages rather than recalculating at the hierarchy level above. I'll play around with summarize some more to find the disconnect.

Solution Specialist

Dear,

Can you share your file to see detail

Frequent Visitor

Unfortunately my organization doesn't allow the uploading of any contents to this site, despite being connected to login via windows authentication. I can't even upload a picture of the layout or structure which is why I had to create the ugly comment table.

The info you've given me so far has leaped me several steps forward in just being able to summarize and calculate off an already calculated measure.

Frequent Visitor

Thank you. I'll give this a try and let you know.

Announcements

#### Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

#### Power BI Monthly Update - August 2024

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

#### Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

#### Fabric Community Update - September 2024

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

Top Solution Authors
Top Kudoed Authors