Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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
MONTHNUMBER | DEPT | TEAM | EMPLOYEECODE | AVGHOURS |
Jan | A | 1 | AX1 | 8.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.
Solved! Go to 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,
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
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
@Rockyalex , Try like
EmployeeCount= CALCULATE(Countx( FIlter( Values('EMP'[EMPLOYEECODE]),[RANK] <=[COUNTROWS]), [EMPLOYEECODE]) )
refer this one from Matt
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,
User | Count |
---|---|
25 | |
12 | |
8 | |
6 | |
6 |
User | Count |
---|---|
26 | |
12 | |
12 | |
10 | |
6 |