Ravindra BagaleCourses & study guides Track your progress

Labs · Power BI

Lab: Plot Sales by Maharashtra District on a Map and Fix Wrong Locations with Data Category

Beginner30 minPower BI Desktop (free) · mh_district_sales.csv · Internet connection (maps)

Course: Power BI · Chapter 15: Maps: Showing Maharashtra on a Map

Chapter 15 is about maps for Maharashtra; this lab plots district sales and fixes the classic wrong-location problem.

Download mh_district_sales.csv (10 districts with lat/long)

Chala mitrano! Maps look impressive, but they have one famous trap: the map service guesses where a name is. "Aurangabad"? There is one in Maharashtra and one in Bihar. Today we make a map of our districts and then remove the guessing completely. Naav purna, jaaga barobar!

Suppose we are…

Suppose we work for Amul's Maharashtra distribution team. The head of sales wants a map of last quarter's sales in 10 districts, to decide where to add a new cold-storage depot. A map is the right visual because the question is about where. The numbers are sample data made up for practice.

The trap: Power BI sends each name to an online map service (Bing Maps for the Map visual, Azure Maps for the newer Azure Maps visual), and the service guesses the place. Aurangabad is also a district in Bihar, and Amravati is very close to Amaravati, the capital region of Andhra Pradesh. Without more context, a bubble can land in the wrong state.

Goal of this lab

By the end you will have:

  • A bubble map of 10 districts sized by Sales (total 2,120,000).
  • Fixed ambiguous names with a Location column ("Aurangabad, Maharashtra, India") and Data category = Place.
  • A second map that uses Latitude and Longitude, so no guessing happens at all.

What you need (all free)

The data: before and after

Before. District names only. Two names are risky.

Before: 10 districts with sales from Mumbai 439,000 to Satara 84,000; Aurangabad and Amravati highlighted as risky names

After. A full place name with a Data category, or exact coordinates.

After: Location "Aurangabad, Maharashtra, India" with Data category Place, Latitude 19.8762 and Longitude 75.3433; result: all 10 bubbles inside Maharashtra

The formula

One DAX calculated column gives the map service the full address:

Location = mh_district_sales[District] & ", Maharashtra, India"

& joins text, so "Aurangabad" becomes "Aurangabad, Maharashtra, India". Then we tell Power BI what kind of value this is with Column tools → Data category → Place. The more specific the text and the category, the less the service has to guess.

Coordinates are even better: Latitude (north–south, about 16 to 22 for Maharashtra) and Longitude (east–west, about 72 to 80) point to one exact spot.

Steps

  1. In Power BI Desktop, check that map visuals are allowed: File → Options and settings → Options → Global → Security, and tick Use Map and Filled Map visuals if you see it. Click OK and restart Power BI if asked.
  2. Get data → Text/CSV → mh_district_sales.csv → Load.

    What you should see: a table with District, Sales, Latitude and Longitude (10 rows).

  3. In Table view, select Latitude and set Column tools → Data category → Latitude and Summarization → Don't summarize. Do the same for Longitude (category Longitude).

  4. In Report view, click the Map icon (the globe) in Visualizations. Location: District, Bubble size: Sales.

    What you should see: bubbles over western India. Zoom out (mouse wheel) and look at the whole country. With names only, a bubble such as Aurangabad or Amravati may appear outside Maharashtra: the result depends on the map service's guess that day.

  5. Now the fix. Go to Table view, select the table and click Table tools → New column. Type the Location formula from above and press Enter.

  6. With the Location column selected, set Column tools → Data category → Place.

    What you should see: a small globe icon next to Location in the Data pane.

  7. Back in Report view, select the map and replace District with Location in the Location box. Put District into Tooltips so the hover text stays short.

    What you should see: all 10 bubbles inside Maharashtra. Mumbai and Thane sit close together on the coast; Nagpur and Amravati in the east.

  8. Make a second map for the exact method: click empty canvas → Map. Put Latitude in Latitude, Longitude in Longitude, Sales in Bubble size and District in Tooltips.

    What you should see: the same 10 bubbles in exactly the same places. Hover over the biggest: Mumbai 439,000.

  9. Give both maps the title Sales by district, Maharashtra. Save as Lab-15-maharashtra-map.

Map, Filled map and Azure Maps

Microsoft plans to retire the Bing-based Map and Filled map visuals and recommends the newer Azure Maps visual. If your Power BI shows an Upgrade maps prompt (it needs a work or school sign-in where your admin has allowed Azure Maps), the same fixes apply: a full place name, the right Data category, or coordinates.

Ravindra Bagale's Tip

Whenever you make a map, zoom out once and look at the whole country or the whole world. A wrong bubble far away is easy to miss when the map auto-zooms to the area. Real companies have shown "Pune" sales in the wrong place in board meetings. Ekda zoom out kara!

Common mistakes

Mistake What happens Fix
Map visual missing or grey Maps are switched off in Options Options → Security → Use Map and Filled Map visuals
Latitude left as Sum Bubbles appear in the sea or at strange places Summarization → Don't summarize for Latitude and Longitude
Latitude and Longitude swapped Bubbles in the Indian Ocean or Central Asia Latitude ≈ 16–22, Longitude ≈ 72–80 for Maharashtra
Location column without Data category Better, but the service still treats it as plain text Data category → Place
Using a Filled map for districts Shapes may not exist for Indian districts Use a bubble Map, or a custom shape map with your own map file
No internet Grey map with no tiles Maps need an internet connection

Self-check checklist

0 of 5 done

Try-at-home challenge

Colour the bubbles by division. Add a column with SWITCH: Mumbai and Thane are Konkan; Pune, Kolhapur, Solapur and Satara are Pune; Nashik is Nashik; Nagpur is Nagpur; Aurangabad is Aurangabad; Amravati is Amravati. Put it in the map's Legend. Which division sells the most?

Check your answer
Division =
SWITCH ( mh_district_sales[District],
    "Mumbai", "Konkan", "Thane", "Konkan",
    "Pune", "Pune", "Kolhapur", "Pune", "Solapur", "Pune", "Satara", "Pune",
    mh_district_sales[District] )

The last argument is the "else" value: Nashik, Nagpur, Aurangabad and Amravati keep their own name, which is also their division. In a table by Division: Pune 690,000 (346 + 142 + 118 + 84 thousand), Konkan 649,000, Nagpur 260,000, Nashik 257,000, Aurangabad 168,000, Amravati 96,000. Pune division is the biggest even though Mumbai is the biggest single district.

Samjla ka? Full place name + Data category, or latitude/longitude, and always zoom out once. Aata pudhe jaauya: drill from year to month and learn every drill button.