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

Try your skills in the Power BI Dataviz World Championship! Round one ends June 26. Join now

Reply
Wendeley-North
Resolver I
Resolver I

Tooltip to return top and bottom 5 results

Hi, would require some help in getting a tooltip to show the top and bottom 5 results correctly. I have managed to get it working in simpler instances, but it seems like once I require grouping, the complication results in a wrong aggregation. I'll share what I've done so far and hope it helps to move the process along.

Use Case

There is currently a scatter chart which plots the weighted sum of Metric1 on the y-axis, and the weights on the x-axis. Each marker here represents a sector.

To accomplish this, there are 3 measures being used:

 

Pct1_Weighted_Metric1 = IFERROR(ROUND(SUMX(Table, Table[Pct1] * Table[Metric1]) / SUM(Table[Pct1]),5), 0)

Pct2_Weighted_Metric1 = IFERROR(ROUND(SUMX(Table, Table[Pct2] * Table[Metric1]) / SUM(Table[Pct2]),5), 0)

Plotted_Metric1 = Pct1_Weighted_Metric1 - Pct2_Weighted_Metric1 

 

What these measures aim to do (since they could be wrong), is to rebase Metric1 based on the sum of Pct1/Pct 2:

  • For example, a normal weighted metric could be: 0.80% x 10 + 0.25% x 12 = 8 + 3 = 12 
  • Rebased would result in: (0.80% x 10 + 0.25% x 12) / (0.80% + 0.25%) = (8 + 3) / (1.05%) = ~1,048

And then take the difference between the two rebased metrics. Before we continue to the tooltip, here's some dummy data.

 

Dummy Data

Unfortunately, the actual data is hard to provide an accurate sample of, but I hope what is presented below gives an idea:

Grouping1DateID_NumPct_1ID_StrPct_2Pct_3Metric1CountryGrouping3Sector
Group1_Str131-Dec-20ID_Num_12.50%ID_Str_10.24%2.27% Country_Str1Group3_Str1Sector_Str1
Group1_Str131-Dec-20ID_Num_21.60%ID_Str_20.35%1.24% Country_Str1Group3_Str1Sector_Str2
Group1_Str131-Dec-20ID_Num_34.18%ID_Str_35.02%-0.83%3.6Country_Str1Group3_Str1Sector_Str2
Group1_Str131-Dec-20ID_Num_40.93%ID_Str_46.73%-5.79% Country_Str2Group3_Str1Sector_Str3
Group1_Str131-Dec-20ID_Num_53.88%ID_Str_50.21%3.67%4.3Country_Str3Group3_Str1Sector_Str4
Group1_Str131-Dec-20ID_Num_60.11%ID_Str_60.62%-0.51%3.9Country_Str1Group3_Str1Sector_Str2
Group1_Str131-Dec-20ID_Num_71.94%ID_Str_75.59%-3.66% Country_Str1Group3_Str1Sector_Str5
Group1_Str131-Dec-20ID_Num_82.18%ID_Str_85.49%-3.30%1.8Country_Str1Group3_Str1Sector_Str6
Group1_Str131-Dec-20ID_Num_92.75%ID_Str_93.54%-0.80%2.7Country_Str2Group3_Str1Sector_Str7
Group1_Str131-Dec-20ID_Num_102.61%ID_Str_100.67%1.94%3.5Country_Str1Group3_Str1Sector_Str4
Group1_Str131-Dec-20ID_Num_116.46%ID_Str_113.86%2.60%4.3Country_Str1Group3_Str1Sector_Str7
Group1_Str131-Dec-20ID_Num_123.70%ID_Str_120.29%3.41% Country_Str1Group3_Str1Sector_Str8
Group1_Str131-Dec-20ID_Num_133.85%ID_Str_132.01%1.84%4.1Country_Str1Group3_Str1Sector_Str4
Group1_Str131-Dec-20ID_Num_142.91%ID_Str_140.90%2.01% Country_Str1Group3_Str1Sector_Str3
Group1_Str131-Dec-20ID_Num_150.52%ID_Str_150.02%0.50%3.3Country_Str2Group3_Str1Sector_Str2
Group1_Str131-Dec-20ID_Num_166.86%ID_Str_164.42%2.44% Country_Str1Group3_Str1Sector_Str4
Group1_Str131-Dec-20ID_Num_175.75%ID_Str_173.33%2.42% Country_Str1Group3_Str1Sector_Str5
Group1_Str131-Dec-20ID_Num_185.42%ID_Str_180.27%5.15%4.5Country_Str2Group3_Str1Sector_Str3
Group1_Str131-Dec-20ID_Num_191.56%ID_Str_192.75%-1.19% Country_Str1Group3_Str1Sector_Str3
Group1_Str131-Dec-20ID_Num_203.22%ID_Str_204.64%-1.42%4.4Country_Str1Group3_Str1Sector_Str2
Group1_Str131-Dec-20ID_Num_215.62%ID_Str_211.45%4.17%4.2Country_Str2Group3_Str1Sector_Str9
Group1_Str131-Dec-20ID_Num_220.95%ID_Str_223.87%-2.93% Country_Str1Group3_Str1Sector_Str3
Group1_Str131-Dec-20ID_Num_230.78%ID_Str_234.07%-3.29% Country_Str1Group3_Str1Sector_Str5
Group1_Str131-Dec-20ID_Num_245.50%ID_Str_246.51%-1.01%4.2Country_Str1Group3_Str1Sector_Str2
Group1_Str131-Dec-20ID_Num_253.28%ID_Str_253.19%0.09% Country_Str1Group3_Str1Sector_Str9
Group1_Str131-Dec-20ID_Num_263.90%ID_Str_266.17%-2.27%3.4Country_Str1Group3_Str1Sector_Str9
Group1_Str131-Dec-20ID_Num_270.51%ID_Str_274.58%-4.07%3.1Country_Str1Group3_Str1Sector_Str2
Group1_Str131-Dec-20ID_Num_281.65%ID_Str_286.29%-4.64%5.3Country_Str1Group3_Str1Sector_Str7
Group1_Str131-Dec-20ID_Num_294.70%ID_Str_295.62%-0.92%3.7Country_Str1Group3_Str1Sector_Str9
Group1_Str131-Dec-20ID_Num_3010.19%ID_Str_307.29%2.89% Country_Str1Group3_Str1Sector_Str4
Group1_Str231-Dec-20ID_Num_2725.00%ID_Str_274.58%20.42%3.1Country_Str1Group3_Str1Sector_Str2
Group1_Str231-Dec-20ID_Num_2825.00%ID_Str_286.29%18.71%5.3Country_Str1Group3_Str1Sector_Str7
Group1_Str231-Dec-20ID_Num_2925.00%ID_Str_295.62%19.38%3.7Country_Str1Group3_Str1Sector_Str9
Group1_Str231-Dec-20ID_Num_3025.00%ID_Str_30-4.16%29.16% Country_Str1Group3_Str1Sector_Str4

 

Tooltip

If the measures presented in the use case were correct (they seem to be), then the charts are fine and dandy. But the tooltips are definitely not. I'm trying to get the tooltip to return the top and bottom ID_Str and Pct1 for the sectors upon mouseover. To do this, I use a measure to create flags, and then put it inside the filter:

Top_Ranker = RANKX ( Table, Plotted_Metric1],, DESC )

Bottom_Ranker = RANKX ( Table, Plotted_Metric1],, ASC)

TopNBtm= IF([Top_Ranker ] <= 5 || [Bottom_Ranker ] <= 5, 1, 0 )

The biggest giveaway as to how I know the tooltip isn't working as intended is that it returns, for a start, more than 10 entries in some instances. 

Additional Information

Slicer Filters Present

  • Grouping_1
  • Grouping_3
  • Date

Visual Filter Present

  • Sector is not blank
  • Metric1 is not blank

Would appreciate any help, thank you.

1 ACCEPTED SOLUTION
Wendeley-North
Resolver I
Resolver I

Managed to solve it by changing the filtering options for the measures - now it uses ALLSELECTED instead of just the row context.

Will note for any future users that stumble upon this solution looking for a ranking measure: depending on your requirements, you may use all filters (i.e. the code presented in the original post), or remove all filters (i.e. using ALL(Table)) instead.

 

Top_Ranker = RANKX ( ALLSELECTED(Table), Plotted_Metric1],, DESC )

Bottom_Ranker = RANKX ( ALLSELECTED(Table), Plotted_Metric1],, ASC)

TopNBtm= IF([Top_Ranker ] <= 5 || [Bottom_Ranker ] <= 5, 1, 0 )

 

 

View solution in original post

1 REPLY 1
Wendeley-North
Resolver I
Resolver I

Managed to solve it by changing the filtering options for the measures - now it uses ALLSELECTED instead of just the row context.

Will note for any future users that stumble upon this solution looking for a ranking measure: depending on your requirements, you may use all filters (i.e. the code presented in the original post), or remove all filters (i.e. using ALL(Table)) instead.

 

Top_Ranker = RANKX ( ALLSELECTED(Table), Plotted_Metric1],, DESC )

Bottom_Ranker = RANKX ( ALLSELECTED(Table), Plotted_Metric1],, ASC)

TopNBtm= IF([Top_Ranker ] <= 5 || [Bottom_Ranker ] <= 5, 1, 0 )

 

 

Helpful resources

Announcements
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.