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
wujunmin
Advocate III
Advocate III

Add any chart/image to map by DAX

wujunmin_3-1642599803367.png

 

wujunmin_2-1642599732929.png

How? 

 

First, you need a SVG map,  you could get them from https://www.amcharts.com/svg-maps/

Download the map and copy the code to Power BI.

wujunmin_4-1642600000632.png

 

Add a new measure, paste the SVG code:

wujunmin_5-1642600105552.png

wujunmin_6-1642600176911.png

The map could be shown by HTML Content:

wujunmin_7-1642600292599.png

 

Second, you need XY Value for every location.

 

wujunmin_8-1642600451500.png

 

Third, creat the chart measure: 

 

 

 

Column_Chart_Map= 
VAR MAX_Value =
    MAXX ( ALL ( 'table'[Province] ), [value] )
VAR MAX_Width = 40
VAR FontSize = 12
VAR Chart =
    CONCATENATEX (
        'table',
        "<text  x='" & [坐标轴_X] & "' y='" & [坐标轴_Y] + FontSize + 1 & "' text-anchor='start' font-size='" & FontSize & "' fill='Grey'>" & [Province] & "</text>" &
        "<rect rx='1' x='" & [坐标轴_X] - 5 & "' y='" & [坐标轴_Y] + FontSize + 1 - MAX_Width * [value] / MAX_Value & "'height='" & MAX_Width * [value] / MAX_Value & "'width='5' fill='"
            & IF ( [value] >= 50, "DarkCyan", "Tomato" ) & "'/>"
    )
RETURN
    SUBSTITUTE ( [MAP], "</svg>", Chart & "</svg>" )
Image_Map= 
VAR MAX_Value =
    MAXX ( ALL ( 'table'[Province] ), [value] )
VAR MAX_Width = 40
VAR FontSize = 12
VAR image = "http://*****.com/****.png
VAR imagemap =
    CONCATENATEX (
        'table',
        "<image xlink:href='" & image & "' x='" & [坐标轴_X] & "' y='" & [坐标轴_Y] & "' width='" & MAX_Width * [value] / MAX_Value & "' height='" & MAX_Width * [value] / MAX_Value & "'></image>" & "<text  x='" & [坐标轴_X] & "' y='" & [坐标轴_Y] + FontSize + 1 & "' text-anchor='start' font-size='" & FontSize & "' fill='Black'>" & [Province] & "</text>"
    )
RETURN
    SUBSTITUTE ( [MAP], "</svg>", imagemap & "</svg>" )

 

 

 

Again, you could see the result by HTML content.

 

0 REPLIES 0

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.

Top Kudoed Authors