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
shanebo3239
Helper I
Helper I

Ranking Employees against peers within a Table

I'll try to explain this the best I can.  We have multiple employees across multiple job titles that perform multiple services.

 

Users Table:

 

UserId | User Name
1         | John
2         | Bob
3         | Susie
4         | Tina
5         | Alan
6         | Tony
7         | Jessica
8         | Carol
9         | Tanya
10       | Jeff

 

JobTitles Table:

 

 

JobTitleId     | Job Title
1     | CSR 1
2     | CSR 2
3     | CSR 3

 

Services Table:

 

ServiceID     | ServiceName
1     |  Mopping
2     |  Sweeping
3     | Vacuuming 
4     | Mowing

 

 

WorkHistory Table:

 

 

ProcessID | UserID | ServiceID | Duration
1 | 1 | 3 | 201
2 | 1 | 4 | 290
3 | 2 | 2 | 380
4 | 2 | 1 | 1200
5 | 3 | 1 | 1260
6 | 2 | 1 | 900
7 | 1 | 2 | 860
8 | 4 | 4 | 201
9 | 5 | 3 | 209
10 | 6 | 2 | 214
11 | 6 | 1 | 217
12 | 6 | 4 | 1290
13 | 7 | 1 | 1500
14 | 8 | 3 | 905
15 | 9 | 1 | 854
16 | 9 | 2 | 802
17 | 10 | 1 | 809
18 | 10 | 3 | 875
19 | 10 | 3 | 901
20 | 1 | 2 | 698
21 | 2 | 1 | 98
22 | 7 | 2 | 202
23 | 9 | 4 | 298
24 | 1 | 3 | 208
25 | 4 | 3 | 1209

EmployeeCareerLevels Table:

 

 

 

UserId | JobTitleId
1 | 2
2 | 2
3 | 1
4 | 3
5 | 3
6 | 2
7 | 1
8 | 1
9 | 2
10 | 2

 

 

I have all of the relationships set up between all of the tables.  From here I want to create a single table visualization that looks something like this:

 

 

Service Name |  Average Time | Average Time of Peers |  Rank Among Peers | Rank Among All
Sweeping | 239 | 302 | 1 | 3
etc

The slicer on the page would have the User's Name.  So selecting the users name would change the values above.  I've got everything basically except the "Rank Among Peers" and "Rank Among All".  My issue is that the slicer MUST filter this visual.  I just need to know what kind of RANK or RANKX function I should be writing to do what Im trying to accomplish.

 

 

1 ACCEPTED SOLUTION
ibarrau
Super User
Super User

Hey there. I think you should play a lilttle with ALL, ALLSELECTED and ALLEXCEP. Add measure like this:

 

= RANKX(ALLEXCEPT(Table; ColumnsFilter); SUM('Table'[Number]) )

 

It dependes on what filter you want to be apply.

ALL -> No filter apply

ALLSELECTED -> Avoid filters in the query and accepts the external ones.

ALLEXCEPT -> receive columns that will filter the measure

 

Regards,


If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Happy to help!

LaDataWeb Blog

View solution in original post

2 REPLIES 2
ibarrau
Super User
Super User

Hey there. I think you should play a lilttle with ALL, ALLSELECTED and ALLEXCEP. Add measure like this:

 

= RANKX(ALLEXCEPT(Table; ColumnsFilter); SUM('Table'[Number]) )

 

It dependes on what filter you want to be apply.

ALL -> No filter apply

ALLSELECTED -> Avoid filters in the query and accepts the external ones.

ALLEXCEPT -> receive columns that will filter the measure

 

Regards,


If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Happy to help!

LaDataWeb Blog

Thank you.  I'll give those a shot.  I've been working with Dax for about 6 months and it still confuses me considerably at times.  But I'll give your samples a shot.

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.