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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Rockyalex
Regular Visitor

Count distinct incorrect on top 20% ranked Data

Hi ,

incorrect distinct employee counts are populating in Matrix created by Department and Team.
I have a EMP table which has Average Hours stored on monthly basis.

The requirement is that I need to populate a Matrix showing distinct count of Employees from top 20% based on slicers used are  Month, Dept,Team, so i created following measures

Table Columsn

MONTHNUMBERDEPTTEAMEMPLOYEECODEAVGHOURS
JanA1AX18.3

 

Rank Calculation

Rank= RANKX(ALLSELECTED('EMP'[EMPLOYEECODE],[AVGHOURS],,ASC,Dense)

 

COUNTROWS=ROUND(COUNTROWS(CALCULATE('EMP[EMPLOYEECODE),ALLSELECTED('EMP'[EMPLOYEECODE))*0.2,0)

This gives rowcount of 20% of selected value

 

EmployeeCount= CALCULATE(DISTINCTCOUNT('EMP'[EMPLOYEECODE]),FILTER(ALLSELECTED('EMP'EMPLOYEECODE),RANK <=[COUNTROWS]))

Above calcualation i have used to calculate the distinct employee count in the Top 20% bucket

 

Any help is appreciated.

 

1 ACCEPTED SOLUTION

Hi Both,

Thank you for your support,

I have resolved this by applying Rank logics as below.

Rank= CALCULATE(RANKX(FILTER(

ALL('EMP'[EMPLOYEECODE]),[AVGHOURS],,ASC,Dense),ALLSELECTED(DEPT),ALLSELECTED(TEAM),ALLSELECTED(MONTHNUMBER)),

 

Kind Regards,

@Rockyalex 

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi @Rockyalex ,

You can refer the following links to get it.

Display TOP N by Count base on 1 Field

Get % of total count while displaying top 10 in Power BI

yingyinr_1-1661934581785.png

 

If the above one can't help you get the desired result, please provide more raw data in EMP table (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

amitchandak
Super User
Super User

@Rockyalex , Try like

 

EmployeeCount= CALCULATE(Countx( FIlter( Values('EMP'[EMPLOYEECODE]),[RANK] <=[COUNTROWS]), [EMPLOYEECODE]) )

 

refer this one from Matt

https://exceleratorbi.com.au/pareto-analysis-in-power-bi/

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi Amit, It didn't work.
the formula didnt evaluate the higlighted column

EmployeeCount= CALCULATE(Countx( FIlter( Values('EMP'[EMPLOYEECODE]),[RANK] <=[COUNTROWS]), [EMPLOYEECODE]) )

 

Thanks,

Alex

Hi Both,

Thank you for your support,

I have resolved this by applying Rank logics as below.

Rank= CALCULATE(RANKX(FILTER(

ALL('EMP'[EMPLOYEECODE]),[AVGHOURS],,ASC,Dense),ALLSELECTED(DEPT),ALLSELECTED(TEAM),ALLSELECTED(MONTHNUMBER)),

 

Kind Regards,

@Rockyalex 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.