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
kimchizal
Helper II
Helper II

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
v-danhe-msft
Employee
Employee

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.
AlB
Super User
Super User

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?

 

 

 

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.

Top Solution Authors