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.
Hey, I'm not experienced with PowerBI and I'm failing to rank the following data:
Name | Group | Segment | Value | Rank | Max Rank |
Jorge | 1 | Small | 9 | 1 | 1 |
Jorge | 1 | Medium | 9 | 1 | 2 |
Gabriel | 1 | Medium | 8 | 2 | 2 |
Maria | 2 | Small | 4 | 3 | 3 |
Maria | 2 | Medium | 4 | 1 | 1 |
Maria | 2 | Big | 5 | 1 | 1 |
Carlos | 2 | Small | 6 | 2 | 3 |
Anthony | 2 | Small | 7 | 1 | 3 |
Louis | 3 | Big | 3 | 1 | 1 |
So, what I want to do is rank those values according to their Group and Segment (column Rank). I also would like to set another column with the number of contestants in each Group-Segment, set as "Max Rank".
I've tried using the RANKX function but I got no luck. Could someone can light me a solution for this problem, please?
Solved! Go to Solution.
Hi @Zerozinho ,
You can use this DAX expression to Rank groups and segments.
Ranki = RANKX(FILTER(ALL('Table'),'Table'[Segment] = MAX ('Table'[Segment]) && 'Table'[Group] = MAX ('Table'[Group])),CALCULATE(Sum('Table'[Value])))
For MAX Rank you can use the following DAX
Counti = COUNTX(FILTER(ALL('Table'),'Table'[Segment] = MAX ('Table'[Segment]) && 'Table'[Group] = MAX ('Table'[Group])),CALCULATE(Sum('Table'[Value])))
Regards,
Harsh Nathani
Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)
let
Origine = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8sovSk9V0lEyBOLg3MScHCBtCeUbKsXqoKrwTU3JLM1FUmIEVuKemFSUmZqDrsgCrACmyDexKDMRKgKzyQSIjcEYXQXcEBMUxyArccpMB5KmKPLOiUU5+cVotphB+RBbHPNKMvLzKtHUmEONgajxyS/NLIa6DWKNMcKaWAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Name = _t, Group = _t, Segment = _t, Value = _t, Rank = _t, #"Max Rank" = _t]),
#"Raggruppate righe" = Table.Group(Origine, {"Group", "Segment"}, {{"MaxRankCalc", each List.Max([Rank]), type nullable text}}),
#"Merge di query eseguito" = Table.NestedJoin(Origine, {"Group", "Segment"}, #"Raggruppate righe", {"Group", "Segment"}, "hhh"),
#"Tabella hhh espansa" = Table.ExpandTableColumn(#"Merge di query eseguito", "hhh", {"MaxRankCalc"}, {"MaxRankCalc"})
in
#"Tabella hhh espansa"
Hi @Zerozinho ,
You can use this DAX expression to Rank groups and segments.
Ranki = RANKX(FILTER(ALL('Table'),'Table'[Segment] = MAX ('Table'[Segment]) && 'Table'[Group] = MAX ('Table'[Group])),CALCULATE(Sum('Table'[Value])))
For MAX Rank you can use the following DAX
Counti = COUNTX(FILTER(ALL('Table'),'Table'[Segment] = MAX ('Table'[Segment]) && 'Table'[Group] = MAX ('Table'[Group])),CALCULATE(Sum('Table'[Value])))
Regards,
Harsh Nathani
Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)
Thank you very much! It worked just fine!
Another question, do you have any idea of how to do the column "Max Rank", that just collect the number of rows in each "peer group" and set it as the Max Rank column in my example?
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.