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

View all the Fabric Data Days sessions on demand. View schedule

Reply
QLB
Frequent Visitor

Add a legend based on a measure on a shape map

Hi, 

 

I need help to customize a shape map.

I have a shape map on which I calculate on each territory a measure called "Value".
Then for each territory, I calculate a rank according to the result of "Value", using a new measure "Rank".

Finally, I color the map with the "Rank" measure (the best territories are in dark).

 

QLB_2-1663322680985.png


My problem is that I want to color the map using a fixed legend, based on a measure 'Rank', to present the territories in 5 groups: "1ère", "De 2 à 5", "De 6 à 9", "De 10 à 13", "De 14 à 15". But when I try that, I lose the color gradient.

QLB_4-1663323579543.png
I've tried this with a legend stored in a table "Legend", or with a measure like :

RANGES = SWITCH(TRUE(),[rank]=1,"1ère",AND([rank]>=2,[rank]<=5),"De 2 à 5")
or like that : 
Legend_label = IF([rank]=1,"1ère", IF([rank]<=5,"De 2 à 5", IF([rank]<=9,"De 6 à 9", IF([rank]<=13,"De 10 à 13", "De 14 à 15"))))

 

I read the following topic on a similar subject : 

https://community.powerbi.com/t5/Desktop/Unable-to-add-measure-legend-in-SHAPE-MAP-that-has-color/m-...

but I don't understand the rule of the Measure : 

Measure =
VAR _t =
    ADDCOLUMNS (
        DISTINCT ( SELECTCOLUMNS ( 'Sheet1', "dis", 'Sheet1'[DISTRICT] ) ),
        "L", 'Sheet1'[Legend]
    )
RETURN
    CALCULATE ( [Stool_adeq.], FILTER ( _t, [L] = MAX ( 'Legend'[Type] ) ) )

 

Is it possible to add a legend based on a measure on a shape map ?

Thanks for any help

 

3 REPLIES 3
QLB
Frequent Visitor

Hi @v-yangliu-msft , 

Did you manage to download my example, and do you have any idea what solution I could implement ?

Thanks for your help.

Anonymous
Not applicable

Hi  @QLB ,

 

Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data. We can better understand the problem and help you

 

Best Regards,

Liu Yang

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

QLB
Frequent Visitor

Hi @Anonymous 

 

yon can find a sample of my pbix on : https://1drv.ms/u/s!An-kgXpI-CYEcX-X_fVBnTI7sLw?e=FSHoHN

 

Thanks for your help !

 

 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors
Top Kudoed Authors