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
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
v-yiruan-msft
Community Support
Community Support

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

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
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/

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
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.