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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
newpbiuser01
Helper IV
Helper IV

Dynamically Rank Table By Different Groups

Hello,

 

I have data that shows sales by team (L3), then rolls that up to sales under a bigger team (L2) which rolls up to the team at L1. 

YearEmployeeTeam L1Team L2Team L3Sales
2020BobTeam A1Team B11Team C11179
2021SallyTeam A1Team B12Team C11251
2022SandraTeam A2Team B21Team C21190
2023BillyTeam A3Team B31Team C31158
2020MikeTeam A1Team B12Team C11333
2023RobertTeam A1Team B12Team C11439
2021SallyTeam A2Team B22Team C22154
2022BillyTeam A3Team B33Team C33348
2024MikeTeam A1Team B11Team C11193
2020DaveTeam A1Team B12Team C11286
2021SallyTeam A2Team B21Team C21139
2023SandraTeam A3Team B31Team C31157
2022AndyTeam A1Team B12Team C11329
2020SandraTeam A1Team B12Team C11477
2021DaveTeam A2Team B22Team C22137
2022SallyTeam A3Team B33Team C33373
2023BobTeam A2Team B23Team C11225
2023SandyTeam A3Team B33Team C31150

 

I need to show a report that shows a list of all employees ranked by sales under each L1, L2 and L3 (seperately)

So, if a user selects to show the employees for 2023, for L1, it should show the Team L1, Team L2 and ranking for the employee by Team L1 (and not L2). 

YearEmployeeTeam Level 1Team Level L2SalesDesired Employee Rank over L1What I'm getting
2023BillyTeam A3Team B315811
2023SandraTeam A3Team B315722
2023SandyTeam A3Team B335031
2023BobTeam A2Team B232511
2023RobertTeam A1Team B123911

For the same year, for ranking by L2 should show the Team L2, Team L3 (one level down), and rank the employees by L2 (ignoring L3):

YearEmployeeTeam Level 2Team Level 3SalesDesired Employee Rank over L2What I'm getting
2023BillyTeam B31Team C3115811
2023SandraTeam B31Team C3115722
2023RobertTeam B12Team C1143911
2023BobTeam B23Team C1122511
2023SandyTeam B33Team C3115013

 

I need to somehow explicitly ignore the one level down order while ranking. How can I do that? 

I'm using the following as my measure:

RANKX(ALLSELECTED('Table'[Employee]), [Sales],,DESC
 
and Sales = sum([Sales])
 
What am I doing wrong? How can I calculate the ranking for each employee by one group and ignore the other groups (while showing the other groups in the visual)? I find that if I were to only show the same group that I'm ranking by, it works, but I need to show one level down in my visual as part of my report. 
YearEmployeeTeam Level 1SalesDesired Employee Rank over L1
2023BillyTeam A3581
2023SandraTeam A3572
2023SandyTeam A3503
2023BobTeam A2251
2023RobertTeam A1391
 
 I'd really appreciate any help!
Thank you!
1 ACCEPTED SOLUTION
ThxAlot
Super User
Super User

ThxAlot_0-1720064968307.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LeanAndPractise(Everyday)


)



View solution in original post

3 REPLIES 3
ThxAlot
Super User
Super User

ThxAlot_0-1720064968307.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LeanAndPractise(Everyday)


)



Thank you! This worked like a charm. Really appreciate it. 

aduguid
Super User
Super User

I would unpivot the team columns to make it a bit easier. Then you can add a measure for the ranking.

User Team Rank = 
VAR _current_year = MAX('Table'[Year])
VAR _current_team_group = MAX('Table'[Team Group])
VAR _current_sales = MAX('Table'[Sales])

RETURN
RANKX(
    ALLSELECTED('Table'),
    CALCULATE(
        MAX('Table'[Sales]),
        'Table'[Year] = _current_year,
        'Table'[Team Group] = _current_team_group
    ),
    _current_sales,
    DESC,
    DENSE
)

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("jZMxD4IwEIX/iunMAHfUwgi6uqgbYYDAQERIiDHx30traK+oLQs5kn59fe+1RcEghJAFLB/r+Xttq/sui5Ypj/R4iNQsUlYGCpJ/l6rvX78wIJicebRgoLChmSrN6cU5GDlQcmm4cCjP2FE51BgaDBXGkwWT1k7drfUdUm6GSMXOY91ODx8XS86RCfFmMFALeUwz+esNjTc1x9pb7PC27i1FmsixenoTkXOy3+Rs3ZoJBL/bdtUmaCLZ0HjvltwMUmptpeaoTQhqzorE0RoK+yZvbE1Yd4s+NqKFzI4f+DpHn9YnxvnRlG8=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Year = _t, Employee = _t, #"Team L1" = _t, #"Team L2" = _t, #"Team L3" = _t, Sales = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Year", Int64.Type}, {"Employee", type text}, {"Team L1", type text}, {"Team L2", type text}, {"Team L3", type text}, {"Sales", Int64.Type}}),
    #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Year", "Employee", "Sales"}, "Attribute", "Value"),
    #"Renamed Columns" = Table.RenameColumns(#"Unpivoted Columns",{{"Attribute", "Team Group"}, {"Value", "Team Value"}})
in
    #"Renamed Columns"

 

aduguid_0-1720061840032.png

 

Helpful resources

Announcements
Sept PBI Carousel

Power BI Monthly Update - September 2024

Check out the September 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

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