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

The FabCon + SQLCon recap series starts April 14th at 8am Pacific. If you’re tracking where AI is going inside Fabric, this first session is a can't miss. Register now

Reply
powerbi2srm
Resolver II
Resolver II

Add text in a shape map by regions

I want to know if I can add text on a shape map in Power BI. I'm looking for how I can add information about regions in each of them, but I can't find a solution.

What I want to say is that, for example, in the region of Catalonia there are 4 million inhabitants. I want this information to appear on the map within the region of Catalonia. Can anyone help me?

1 ACCEPTED SOLUTION
powerbi2srm
Resolver II
Resolver II

I solved my problem:
It's not possible with shape maps. For solve this problem, it's necessary to use R or Python Script.
- Firtsly, you have to drag the variables what you're going to use onto the python visual. For example, "regions" and "num_inhabitants"

- Secondly, you need to read your geojson field and merging with default dataset (composed by dragged variables):

 

 

 

import geopandas as gpd
import matplotlib.pyplot as plt

# Reading geojson
mapa = gpd.read_file('map.geojson')

# Merging by the common column
mapa_pedidos_venta = mapa.merge(dataset, left_on='region_name', right_on=dataset.region_name)

 

 

 

Careful! It's essential that two columns that you're going to merge having exactly the same names. For example, "Catalonia" have to be on both map.geojson and the region field.

 

Then you can displaying the map and add labels with something like this:

 

 

 

# Plotting the map
mapa_pedidos_venta.plot()

#Adding labels
for idx, row in mapa_pedidos_venta.iterrows():
    labels = '{:.2%}'.format(row['inhabitants'])
    plt.annotate(text=etiqueta, xy=row['geometry'].centroid.coords[0], ha='center', fontsize=40)

# Displaying the map
plt.show()

 

 

 

"geometry" is the name of the column of geojson file that contains the coordinates.

View solution in original post

2 REPLIES 2
powerbi2srm
Resolver II
Resolver II

I solved my problem:
It's not possible with shape maps. For solve this problem, it's necessary to use R or Python Script.
- Firtsly, you have to drag the variables what you're going to use onto the python visual. For example, "regions" and "num_inhabitants"

- Secondly, you need to read your geojson field and merging with default dataset (composed by dragged variables):

 

 

 

import geopandas as gpd
import matplotlib.pyplot as plt

# Reading geojson
mapa = gpd.read_file('map.geojson')

# Merging by the common column
mapa_pedidos_venta = mapa.merge(dataset, left_on='region_name', right_on=dataset.region_name)

 

 

 

Careful! It's essential that two columns that you're going to merge having exactly the same names. For example, "Catalonia" have to be on both map.geojson and the region field.

 

Then you can displaying the map and add labels with something like this:

 

 

 

# Plotting the map
mapa_pedidos_venta.plot()

#Adding labels
for idx, row in mapa_pedidos_venta.iterrows():
    labels = '{:.2%}'.format(row['inhabitants'])
    plt.annotate(text=etiqueta, xy=row['geometry'].centroid.coords[0], ha='center', fontsize=40)

# Displaying the map
plt.show()

 

 

 

"geometry" is the name of the column of geojson file that contains the coordinates.

Anonymous
Not applicable

Hi @powerbi2srm ,

 

According to your description, do you want to show the population of the country in the shape chart, right?

After enabling the preview feature of Shape Map, get the data from Regions Excel file, which includes data set as below;

vtangjiemsft_0-1676862091535.png

To get the first view of this visual, you need to drag and drop a field into it. Start with using Region as the Location, and Use Population as Color Saturation.

vtangjiemsft_2-1676862155301.png

Or you can also convert the details to a .json file to add to the PBIX file.

Please refer: Use Shape maps in Power BI Desktop (Preview) - Power BI | Microsoft Learn

Shape Map Better than the Filled Map - RADACAD

 

Best Regards,

Neeko Tang

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

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

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.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

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