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

The 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.

Reply
Syndicate_Admin
Administrator
Administrator

Show a top 10 of the highest and lowest values in the same graph

Hello good afternoon everyone,

I have a graph in power bi that shows a calculation that is basically a division, and I need to show the top 10 of the highest values and at the same time the lowest ones that in my case are going to be negative values, I have to show this in a bar graph but I can't find a way to do it.

I hope you can help me.

5 REPLIES 5
Ritaf1983
Super User
Super User

Hi @Syndicate_Admin 
To achieve a goal you can create these 3 measures.
I use my example, you can modify it for your parameters.

I have a table with profits and let's try to show the top 10 and bottom 10 countries by profits.
1. Ranking descending ( to get top 10).

Rank top profits = RANKX(ALLSELECTED(Customers[Country]),[profits _ %],,DESC,Dense)
2. Ranking ascending (to get bottom 10)
Rank bottom profits = RANKX(ALLSELECTED(Customers[Country]),[profits _ %],,ASC,Dense)
3. Flag measure wich will assist us to filter the graph
flag_top_bottom =
var
topFlag = if([Rank top profits]>=1 && [Rank top profits]<=10,1,0)
var
bottomFlag =if([Rank bottom profits]>=1&&[Rank bottom profits]<=10,1,0)
Return
if(topFlag=1 || bottomFlag=1,1,0)
4. measure for coloring top and bottom with different colors ( optional)
TopFlagColor = if([Rank top profits]>=1 && [Rank top profits]<=10,"#2b83ba","#d7191c
")
Now let's drag  country , profits and all those to the graph:
Ritaf1983_0-1722134976400.png

for colors, we can use conditional formatting based on the measure :

Ritaf1983_1-1722135075024.png

Result :

Ritaf1983_2-1722135105568.png

Pbix is attached

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

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

Hello thank you very much for your answer, the situation I have is that the measurement I want the top 10 of seniors and minors in turn uses other measurements that in total use 3 different tables, I have not found how to adapt the measurement to that scenario.

Hi @Syndicate_Admin 

Can you please share a pbix or some dummy data that keep the raw data structure with expected results? It should help us clarify your scenario and test to coding formula.

How to Get Your Question Answered Quickly  

 

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile
aduguid
Super User
Super User

Try this measure. Change [YourValue] out for the measure that is doing your division. 

TopAndBottom10Combined = 
VAR HighestRanked = 
    RANKX(ALL('YourTable'), [YourValue], , DESC, DENSE)
VAR LowestRanked = 
    RANKX(ALL('YourTable'), [YourValue], , ASC, DENSE)
RETURN
    IF(
        (HighestRanked <= 10) || (LowestRanked <= 10 && [YourValue] < 0),
        [YourValue],
        BLANK()
    )

 

I did not find a way to apply it because the measure I used in turn uses other measures that in total use data from three different tables, I do not know how it would be applied.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

Feb2025 NL Carousel

Fabric Community Update - February 2025

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

Top Kudoed Authors