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
CamIAm88
Regular Visitor

Help with ranking Employees for each group using RANKX

I have a dashboard created where the user selects an employee and a table displays metrics for all the work groups worked by that employee. I would like to add a column to the table on my dashboard that displays how that KPI ranks amongst all other users for that group. Please note, I would like to create a measure since my model is large and I am running low on space.

 

Below are examples of my existing data and the DAX I'm currently using to calculate the tranking:

 

DAX:

 

 

 

RankEmployee = 
RANKX(
    FILTER(
        ALL(Table_1[Employee_A], (Table_1[Work_Group]),
        Table_1[Work_Group] = MAX(Table_1[Work_Group])
        ),
        CALCULATE( SUM( Table_1[KPI]) ) -- Note actual calculate simplified for example
 	)

 

 

 

Example of Existing Table (3 columns, Employee, Work_Group, KPI):

 

EmployeeWork_GroupKPI
AWork Type A100
AWork Type B10
AWork Type C50
BWork Type A90
BWork Type B45
BWork Type C1
CWork Type A80
CWork Type B60

 

Example of the desired outcome for the table in the dashboard (4 columns, Employee, Work_Group, KPI, Rank):

 

EmployeeWork_GroupKPIRank
AWork Type A1001
AWork Type B103
AWork Type C501
BWork Type A902
BWork Type B452
BWork Type C12
CWork Type A803
CWork Type B601

 

 

1 ACCEPTED SOLUTION
v-jianboli-msft
Community Support
Community Support

Hi @CamIAm88 ,

 

Please try:

RankEmployee =
VAR _a =
    ADDCOLUMNS (
        ALL ( Table_1 ),
        "Rank",
            RANKX (
                FILTER ( ALL ( Table_1 ), [Work_Group] = EARLIER ( Table_1[Work_Group] ) ),
                [KPI]
            )
    )
RETURN
    MAXX (
        FILTER (
            _a,
            [Employee] = MAX ( 'Table_1'[Employee] )
                && [Work_Group] = MAX ( 'Table_1'[Work_Group] )
        ),
        [Rank]
    )

 

Final output:

vjianbolimsft_0-1668159686774.png

Best Regards,

Jianbo Li

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

View solution in original post

3 REPLIES 3
v-jianboli-msft
Community Support
Community Support

Hi @CamIAm88 ,

 

Please try:

RankEmployee =
VAR _a =
    ADDCOLUMNS (
        ALL ( Table_1 ),
        "Rank",
            RANKX (
                FILTER ( ALL ( Table_1 ), [Work_Group] = EARLIER ( Table_1[Work_Group] ) ),
                [KPI]
            )
    )
RETURN
    MAXX (
        FILTER (
            _a,
            [Employee] = MAX ( 'Table_1'[Employee] )
                && [Work_Group] = MAX ( 'Table_1'[Work_Group] )
        ),
        [Rank]
    )

 

Final output:

vjianbolimsft_0-1668159686774.png

Best Regards,

Jianbo Li

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

@CamIAm88 , The measure you provided should work with small change

 

RankEmployee =
RANKX(
FILTER(
ALL(Table_1[Employee_A], (Table_1[Work_Group]),
Table_1[Work_Group] = MAX(Table_1[Work_Group])
)),
CALCULATE( SUM( Table_1[KPI]) ) -- Note actual calculate simplified for example
)

Thank you for your quick response Amit. There was a typo in my DAX after rewriting it for the post but where I'm having the issue is with the results. The DAX designates a rank 1 to all work groups.

 

I would like for the measure to compare the KPI for the selected employee to that of all employees per Work_Group. 

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.