Forum Discussion

DouweMeer's avatar
DouweMeer
Impactful Individual
7 months ago
Solved

Microsoft Azure's map can identify incorrect postal codes - where data?

When I plot data in the maps visual, I sometimes get European postal codes show up in the USA. Both country and postal are in the correct format, with exception that the postal code is invalid for that country. 

 

What it seems to do, and seems to know, is find where that postal code is valid and plots it in that country instead. Otherwise, there's not reason to show this in the USA in the first place. 

AUT being Australia Austria being the right 3 letter ISO code for that country, though 34771 is not a valid postal code for Austria. It is for the USA, thus shows it there instead. Considering the visual knows where 34771 for USA should be shown, I should be able to query somewhere a list of postal codes the visual considers as correct. 

 

Any way to gain access to the list of country + postal code that the visual utilizes to plot its data? 

 

 

  • Azure Maps geocoding is a black-box service: Power BI sends your location fields to the geocoder and gets back coordinates. Microsoft/Azure doesn’t publish the full country+postal reference dataset used for geocoding, and Power BI doesn’t expose it.

     

    What you’re seeing is normal geocoder behavior: if the postal code is invalid for the supplied country (or the country hint isn’t applied strongly enough), it may fallback and resolve the postal code somewhere else (often the US if it’s a valid US ZIP).

     

    Practical ways to reduce wrong matches:

    • Use the correct field category: set Country to Country/Region and Postal to Postal code.

    • Prefer 2-letter ISO country codes (AT) over 3-letter (AUT) if possible; some geocoders handle them more reliably.

    • Add more context (City/State/Region) so the geocoder has less ambiguity.

    • Best: bring your own lat/long (or a reference table that maps valid postal+country to lat/long) and plot by coordinates. That bypasses geocoding entirely.

8 Replies

  • Azure Maps geocoding is a black-box service: Power BI sends your location fields to the geocoder and gets back coordinates. Microsoft/Azure doesn’t publish the full country+postal reference dataset used for geocoding, and Power BI doesn’t expose it.

     

    What you’re seeing is normal geocoder behavior: if the postal code is invalid for the supplied country (or the country hint isn’t applied strongly enough), it may fallback and resolve the postal code somewhere else (often the US if it’s a valid US ZIP).

     

    Practical ways to reduce wrong matches:

    • Use the correct field category: set Country to Country/Region and Postal to Postal code.

    • Prefer 2-letter ISO country codes (AT) over 3-letter (AUT) if possible; some geocoders handle them more reliably.

    • Add more context (City/State/Region) so the geocoder has less ambiguity.

    • Best: bring your own lat/long (or a reference table that maps valid postal+country to lat/long) and plot by coordinates. That bypasses geocoding entirely.

  • Hi DouweMeer , 

    as cengizhanarslan already mentioned, Azure Maps geocoding is a black-box service. 

     

    But it's often worth being a little creative when working with Azure Maps.

     

    You can build a new column like this one: 

    Location With Postal Code And Country ID = 'Table'[Postal Code] & "," & 'Table'[Country ID]
    Taking that column as location, Azure Maps does what you want.
     
    My test data:

     

    The result:

    The invalid postal code leads to a dot in the middle of austria. It's up to you to adapt color or tooltip according to your needs.

     

    Hope that helps.

    • DouweMeer's avatar
      DouweMeer
      Impactful Individual

      Tried it today. Shows only USA country code data in Puerto Rico. As soon as I filter to AUT as country, the map becomes empty. 

       

      Sample of concatenated values:

       

      No dot

       

      Also tried to swap the country postal code and use a different separator, same behavior. Only Puerto Rico showing with US data and empty map on anything else. 

      • Hans-Georg_Puls's avatar
        Hans-Georg_Puls
        Super User

        Hi DouweMeer ,

        it looks like you assigned the new concatenated column as a second location and kept your original location as the first assigned location. That leads to a hierarchy. Do you need a hierarchy? It doesn't surprise me that the results are still confusing.

         

        To reproduce my solution you should assign only the new concatenated column as location. That should work.

  • Hi DouweMeer 

     

    1.Concatenate Country + Postal code for unique keys
    dax
    Create a calculated column in your data
    LocationKey =
    [Country_Code] & "|" & [Postal_Code]

    // Or for display purposes
    DisplayLocation =
    [Country_Code] & " - " & [Postal_Code]

     

    2. Use Latitude/Longitude Instead
    The most reliable solution is to geocode your data beforehand
    Power Query Geocoding (using external API)

    powerquery
    // Add column using Bing Maps or Google Maps API
    = Json.Document(Web.Contents("https://dev.virtualearth.net/REST/v1/Locations/" & [Country] & "/" & [PostalCode] & "?key=YOUR_KEY"))

     

    3. Custom Shapefiles with Correct Boundaries
    Create custom maps with correct country-postal code associations.

     

    4. Azure Maps Data Source Configuration
    If using Azure Maps directly (not Power BI's built-in), you can
    Create a dataset in Azure Maps with correct postal codes
    Use the countrySet parameter to restrict searches

     

    Please mark it as a solution with headup if this helps you. Thank You!

  • v-aatheeque's avatar
    v-aatheeque
    Community Support

    Hi DouweMeer 

    Have you had a chance to look through the responses shared earlier? If anything is still unclear, we’ll be happy to provide additional support.