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?

 

 

 

Community Support Team
Community Support Team

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.