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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
emilne
Frequent Visitor

Map Colour-Coded by Category

I have a table that contains the total number of items assigned to a label (see below) and I am trying to create a shape map that fills in each location based on the label with the maximum. (So for this example, CAN=red for Apple, MEX=orange for Apricot, USA=yellow for Banana).

 

CountryLabelSubcategoryTotal
CANAppleA33
CANBananaB22
CANApricotA1
MEXApricotA55
MEXBananaB22
MEXAppleA6
USABananaB100
USAAppleA8
USAApricotA99

 

I've tried calculating the rank for each label in Power Query and filtering the visual so that Rank equals 1, which works when all values are selected but stops working when I add a slicer that filters by category (since in some cases, the maximum value ranks as 2 overall but 1 within a category). I also tried calculating ranks for each category individually, but this doesn't work when selecting all or multiple categories.

 

emilne_0-1729699725137.png

 

 

I also tried creating a measure that gets the maximum value for each region dynamically but I can't figure out how to connect it to the labels for the legend so that they don't all show up as the first value (Apple).

emilne_1-1729699837841.png

 

How can I create a legend that indicates the maximum value dynamically? Is this possible in Power BI?

1 ACCEPTED SOLUTION
emilne
Frequent Visitor

Thanks, I wanted to apply the color to the legend so it would calculate the max value no matter which categories were selected. I was able to solve it filtering the visual on the measure Ranking==1: 

 
RankTotal = SUM('Census'[Total])
Ranking = RANKX(ALL('Census'[Label]), [RankTotal])
 

View solution in original post

2 REPLIES 2
emilne
Frequent Visitor

Thanks, I wanted to apply the color to the legend so it would calculate the max value no matter which categories were selected. I was able to solve it filtering the visual on the measure Ranking==1: 

 
RankTotal = SUM('Census'[Total])
Ranking = RANKX(ALL('Census'[Label]), [RankTotal])
 
Anonymous
Not applicable

Hi, @emilne 

After reading through your requirements, I'm sorry to say that it wasn't possible to determine what effect you ultimately want to achieve, whether you want to apply the color to the legend or the background color or something else. What do you mean by dynamic legend effect? Thanks for your understanding.

Best Regards,
Yang
Community Support Team



Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.