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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
kevcb226
Regular Visitor

Custom legend for shape map not working

Hi,

I'm hoping someone can help, I'm having difficulty creating a custom legend to add to a shape map.

I've created three measures to calculate a percentage figure, which works perfectly.

 

 

 

ActualAttendance = CALCULATE(SUM(tSCL_Attendance_For_Dash[MarkTypeStatusID]), tSCL_Attendance_For_Dash[MarkTypeStatusID] <> 2)
PossibleAttendance = CALCULATE(COUNT(tSCL_Attendance_For_Dash[MarkTypeStatusID]), tSCL_Attendance_For_Dash[MarkTypeStatusID] <> 2)

 

 

 

Percentage measure:

 

 

PercentageAttendance = DIVIDE([ActualAttendance], [PossibleAttendance], 0)

 

 

 

Then I've created a new calculated column to show as a legend, but also to add a range, however, this doesn't appear to work when I add this to the legend on the shape map.

 

 

Legend = SWITCH(TRUE(), [PercentageAttendance] < 0.3, "Less than 30%", AND([PercentageAttendance] >= 0.3, [PercentageAttendance] <= 0.5), "Between 30% and 50%", AND([PercentageAttendance] > 0.5, [PercentageAttendance] <= 0.8), "Between 50% and 80%", "Over 80%")

 

 

 
This adds the legend to the shape map, but doesn't seem to work correctly. It only adds two values, despite there being more percentages that should be assigned to other values. It also doesn't label them correctly, and they all under in the 'Less than 30%' value. This is what the map looks like when adding the legend:

kevcb226_0-1668064467879.png

Also when I hover over the map, the tooltip seems to show the percentage figure as 0%.

kevcb226_1-1668064580766.png

I've found that I can show the percentage figure in the tooltip by changing the Legend column to the following:

 

 

 

Legend = SWITCH(TRUE(), [PercentageAttendance] < 30, "Less than 30%", AND([PercentageAttendance] >= 30, [PercentageAttendance] <= 50), "Between 30% and 50%", AND([PercentageAttendance] > 50, [PercentageAttendance] <= 80), "Between 50% and 80%", "Over 80%")

 

 

 

However, what that seems to do is show everything in the one value of 'Less than 30%'.

 

kevcb226_2-1668064745217.png

 

Am I doing this the correct way, or should I be doing something different?

1 REPLY 1
amitchandak
Super User
Super User

@kevcb226 , Only one legend can be shown.

 

You can show the Top category. example 

Winner/Topper on Map: How to Color States on a Map with Winners/Runner-ups, Top Brand, Top Category : https://community.powerbi.com/t5/Community-Blog/Winner-Topper-on-Map-How-to-Color-States-on-a-Map-wi...

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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