cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
kimchizal Regular Visitor
Regular Visitor

Calculating percentages within a group

I'd like to calculate count percentages within a group, not group percentages of an entire field/data set

 

Here's the measure:

% of Students Growth > 1 = DIVIDE(CALCULATE(COUNTROWS(SAYOT_Student_diff), SAYOT_Student_diff[Diff] > 1), COUNTROWS(SAYOT_Student_diff))

 

In English, the logic is to calculate the percentage of rows where Diff was greater than 1 per category, which is another field in the table

The measure works fine when no filters are applied, but produces weird results whenever I apply a filter. I've looked into ALLSELECTED but wasn't getting anything out of that

 

2 REPLIES 2
Super User
Super User

Re: Calculating percentages within a group

Hi @kimchizal

 

Can you show your data model or share the pbix?

Is this the only table in your model? What slicers are you using when the measure doesn't work as expected?

 

 

 

v-danhe-msft Super Contributor
Super Contributor

Re: Calculating percentages within a group

Hi @kimchizal,

Based on my test, you could refer to below formula:

Sample data:

1.PNG

Create below measure:

% of Students Growth > 1 = DIVIDE(CALCULATE(COUNT(SAYOT_Student_diff[Diff]),FILTER(ALL(SAYOT_Student_diff), SAYOT_Student_diff[Diff] > 1)), COUNTROWS(ALL(SAYOT_Student_diff)))

Result:

1.PNG

You could also download the pbix file to have a view.

 

Regards,

Daniel He

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

Helpful resources

Announcements
Can You Solve These Challenge

Challenge: Can You Solve These?

Find out how to participate in the first Power BI 'Can You Solve These?' challenge.

Community News & Announcements

Community News & Announcements

Get your latest community news and announcements.

Virtual Launch Event

Microsoft Business Applications October Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

Community Kudopalooza

Win Power BI Swag with Community Kudopalooza!

Each week, complete activities and be qualified in the drawing for cool Power BI Swag.

Users Online
Currently online: 116 members 1,638 guests
Please welcome our newest community members: