4 Replies Latest reply on Oct 29, 2018 5:26 AM by Ombir Rathee

    Obtaining Zip Code Data

    Michael Kaminski

      Hello Everyone,

       

      I am creating a map based on the zip codes of clients and their support managers.  However, I do not have all the zip codes of my clients, but I do have their street address and state.  Is there a way in which Tableau is able download, and/or obtain, the information (zip codes) that I am missing?

      Any help filling in my missing data is much appreciated.  -Mike

        • 1. Re: Obtaining Zip Code Data
          Simon Runc

          hi Michael,

           

          Not that I'm aware of in Tableau. If you have access to Google Sheets you can write a custom function to do this for you (btw I'm go GoogleAppScript expert, I just found this code on-line and checked it worked!)

           

          function address2zip(a) {

            var response=Maps.newGeocoder()

              .reverseGeocode(lat(a),long(a));

            return response.results[0].formatted_address.split(',')[2].trim().split(' ')[1];

          }

           

          function lat(pointa) {

           

          var response = Maps.newGeocoder()

               .geocode(pointa);

            return response.results[0].geometry.location.lat

          }

          function long(pointa) {

            var response = Maps.newGeocoder()

               .geocode(pointa);

            return response.results[0].geometry.location.lng

          }

           

          Once you have this you can enable it and then just use it like a regular GSheet function =address2zip(A1) for example (with your address in cell A1.

           

          There might be better, and easier, ways but if you've only got a few it's a quick and dirty option

           

           

          • 2. Re: Obtaining Zip Code Data
            Michael Kaminski

            This seems like a lot more effort than I want to try. Plus, I am not a expert (at all) in writing scripts and/or code. That’s why I am using Tableau for visualizations.

             

            I was hoping there might be an easy place to find the zip codes via a street address – other than typing each one into Google Maps. Thanks for your help though.

            • 3. Re: Obtaining Zip Code Data
              Simon Runc

              Cool. Yes it's a shame we can't do this directly in Tableau. I think any (non manual) solution would require some code/script. I chose GSheet as this requires no other downloads (unlike doing it in python via the Google API), and you can just follow the instructions (a bit like implementing an Excel VBA macro, without having any VBA knowledge). Or would require you to pay for it (eg. TomTom data).

               

              I'm UK based, so not sure what the US Postal Service offer in terms of bulk zip codes from addresses (might be worth having a look at their site)

              • 4. Re: Obtaining Zip Code Data
                Ombir Rathee

                Once i created vba code to find the distance between two points using Google api distance matrix. That can be modified to find the zip codes but before that i need your some sample data to experiment ?