COVID 19 Dashboard – Article 5 – Working with maps

I will continue to build on my earlier posts about my COVID19 Dashboard.  In this series, I am writing a few different blog articles describing not only how I built it, but some things I learned in the process.
The current list of planned topics include:

PART 5 – Working with maps
I will be the first to admit, I have not used the mapping features in Power BI very often.  I have used them for some simple demos, but being an accountant, I am more often interested in the numbers versus the visual location.  However, when analyzing a global pandemic, I felt a map visual or two might be important.
So without going to any custom visuals, there are four map visualizations in Power BI. 
  • Map
  • Filled Map
  • Shape Map
  • ArcGIS Map for Power Bi

There is a lot of documentation on the map visuals on Microsoft Doc https://docs.microsoft.com/en-us/power-bi/visuals/power-bi-map-tips-and-tricks

After some playing around, including downloading some of the custom map visuals that are available, I decided I was going to use the Shape Map visual that is currently in preview.

Step 1 – Make sure the Preview Option is turned on



Step 2 – Choosing the desired shape map

The standard visual comes with several shapes.  I my case, I was started with a map of the USA, so I selected that map. 



Step 3 – Making sure your data works with the Shape Visual

The shape visual does not use precise geographical locations for data points.  It uses regions that are entered in the location field for the visual.    These regions need to line with the map keys.   That you can check on the formatting pane under the shape visual.


Step 4 – Add your measure to the color saturation field

Your measure will be used to set the color saturation level for each region.  In my report, I used Total Cases per 100k.  However, I did not like how the colors initially looked, so I went to the formatting pane.  Under Data color, I was able to select the color I wanted to use, and I could also set the level for the rate of the color change.











Step 5 – My map really needs a legend to explain the color

I was happy with my map, but it was missing one element.  A legend to explain the colors.  I tried using the legend field, but that required a column and not a measure, so I was struggling.  At first, I decided to simply make an image for my legend. 

This worked, but I felt there must be a better option.  After some playing around with DAX, I was able to create a new column in my State table to group my states by the Cases per 100k.

Cases per 100k =
VAR Per100k = SUMMARIZE(ADDCOLUMNS('US Postal Codes',"Field",[Total Cases per 100k]),"Field",[Total Cases per 100k])
RETURN
if(Per100k < 50, "0 to 50", if(per100k <100, "51 to 100", if(per100k < 200, "101 to 250", if(per100k <500, "501 to 1000", "1001 and more"))))

I used this new column in my legend field and set the data colors for the five groups.


NOTE: I also created a second column using the above formula, but replacing the group names with numbers, so I could sort the legend using Sort by column functionality.

Step 6 – Zoom in for selection

The last thing I turned on for the visualization was Auto Zoom and Selection Zoom.
 
When a selection in made in this visual or another visual with interaction to this visual, the map will zoom to the selected region.

Step 7 – Finally, I need a World Map

One nice thing about this visual is you can add your own shape maps.  I wanted to repeat all of these steps for the Global data, but a world map is not part of the standard visualization.  Well after some internet searching, I found a nice JSON map on Github at https://github.com/deldersveld/topojson/blob/master/world-countries-sans-antarctica.json .  I downloaded the map and uploaded it as a custom map.



Hopefully this will help you with adding maps and shapes to your reports.


What's Next?

With the safe at home still planned for a few more weeks, I will probably continue adding some articles and making changes to the report.  If you have questions about my report or Power BI in general, please do not hesitate to leave a comment or question.  It will help me add some additional articles.
Stay healthy and stay safe

Comments

Popular posts from this blog

Creating a date table with a fiscal year in your Power BI data model

Showing the last 12 months based on a date slicer

Using Excel, OneDrive and Power Automate for Dynamics 365 Finance & Supply Chains Journals