Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code FABINSIDER for a $400 discount.
Register nowThe Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.
Hi,
Hoping for some direction. Never done this before and in a time crunch
I have a table of names with certain measures like below. there are 100's of names. I need to highlight the Top N names. First by C%, then d% then r%
is it possible to do this? and change the ordering depending on the ask. the measures would remain the same,
Name | C% | d% | r% |
tt | 20% | 45% | 25% |
tr | 10% | 55% | 24% |
rt | 5% | 75% | 26% |
Solved! Go to Solution.
Seems than is enough the only Table.MaxN function to get the expected result, when the values are positive:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("bZLLDcQgDER7QdpbDtg4fGqJ0gSify3YbDRhuVhiXmZiY67LteYOx/7Tq5yjcq/30UHtB1JwGhADdThUSabHaRh62Oh10RPkbHTrKALIGKQOkoxEo4SURP2AC4TtSV1J8JBm0kLaPyFI2xJNyxEJgycnu3RBop4yb1EnHWM/HZBnm55eSBdmG/shXNlEwRdEDRFbf68XENh+kh50fwE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Name = _t, #"C%" = _t, #"d%" = _t, #"r%" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"C%", Percentage.Type}, {"d%", Percentage.Type}, {"r%", Percentage.Type}}),
besten = Table.MaxN(#"Changed Type",{"C%"},10)
in
besten
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("bdFbDoQgDAXQvZDMn5PQ8l6LcROE/UfoVac4/DSxx15e+25aM5th++nVh1G512PrUPsHCQSAB9QxIZ2EfrwGRv/rFlDfkFTSChA15h/JU5bMkM+akOZJKMofXHTemuofOasD0XtRWxDpwCUhMEdNrKdywgt4TZgq15XKkcf5f9sgy7gHmkwSCS94m37C25wt2tpkjF2GKdMxFkqPHSc=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Name = _t, #"C%" = _t, #"d%" = _t, #"r%" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Name", type text}, {"C%", Percentage.Type}, {"d%", Percentage.Type}, {"r%", Percentage.Type}}),
tBestTen=Table.FirstN(Table.Sort(#"Changed Type",{"C%","d%","r%"}),10)
in
tBestTen
Seems than is enough the only Table.MaxN function to get the expected result, when the values are positive:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("bZLLDcQgDER7QdpbDtg4fGqJ0gSify3YbDRhuVhiXmZiY67LteYOx/7Tq5yjcq/30UHtB1JwGhADdThUSabHaRh62Oh10RPkbHTrKALIGKQOkoxEo4SURP2AC4TtSV1J8JBm0kLaPyFI2xJNyxEJgycnu3RBop4yb1EnHWM/HZBnm55eSBdmG/shXNlEwRdEDRFbf68XENh+kh50fwE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Name = _t, #"C%" = _t, #"d%" = _t, #"r%" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"C%", Percentage.Type}, {"d%", Percentage.Type}, {"r%", Percentage.Type}}),
besten = Table.MaxN(#"Changed Type",{"C%"},10)
in
besten
Hello @NOVICE02
I don't know if I get you right. Check out this solution. Depending on the variable "Task" the table is sorted differently. Just change the variable "Task" accordingly to change the result.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WKilR0lEyMlAFkiamINIISMbqACWKgBxDsIQpRMIEIlEE0gEWMYeImwHFYwE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Name = _t, #"C%" = _t, #"d%" = _t, #"r%" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Name", type text}, {"C%", Percentage.Type}, {"d%", Percentage.Type}, {"r%", Percentage.Type}}),
//Variable for ordering c, d or r allowed
Task = "d",
Top2N = if Task = "c" then
Table.FirstN(Table.Sort(#"Changed Type", {{"C%", Order.Descending}}),2) else
if Task = "d" then
Table.FirstN(Table.Sort(#"Changed Type", {{"d%", Order.Descending}}),2) else
if Task = "r" then
Table.FirstN(Table.Sort(#"Changed Type", {{"r%", Order.Descending}}),2) else "wrong task variable"
in
Top2N
Copy paste this code to the advanced editor in a new blank query to see how the solution works.
If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too
Have fun
Jimmy
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the February 2025 Power BI update to learn about new features.
User | Count |
---|---|
27 | |
25 | |
24 | |
13 | |
10 |
User | Count |
---|---|
25 | |
20 | |
20 | |
19 | |
11 |