3 Replies Latest reply on Jan 17, 2020 9:07 AM by LaRae Punt

    Distance Between two zip codes calculation.

    LaRae Punt

      I am wanting to harness the work already being done by Tableau with the spatial distance ability in maps.

      I have a patients zip code and a primary care physicians zip code. I need to know the difference between the two.

      Ideas? I was hoping I could click on a map measure my distance I am looking for and then export those records into a table.

      On the flip side of that if I just had a calculation to put in a calculated field that would be great, and the map unnecessary.


      Thank you!!



        • 2. Re: Distance Between two zip codes calculation.
          Jim Dehner


          You need the actual long and lat to do the distance calculations - you can't use those "generated" by tableau in formulas

          You can get the zip centroid long and lat from US Census bureau Tiger files - the file is extensive so if you are confined to a state you can filter to that state before downloading

          but bear in mind they are not street address longs and lats - they are the long and lat of the center of the zip code area


          you can then use the longs and lats in the Distance spatial formula in Tableau




          If this posts assists in resolving the question, please mark it helpful or as the 'correct answer' if it resolves the question. This will help other users find the same answer/resolution.  Thank you.

          • 3. Re: Distance Between two zip codes calculation.
            LaRae Punt

            Jim, thank you for your reply. I did exactly that yesterday, (could not wait, but your confirmation to know you cannot use the lat and long in Tableau is good info) I ran the csv file through prep to separate and name. I then brought in the exact long and lat of the clinic, modified the spatial formula, and wala! LOVE me some Tableau. In the tabular report I had created a filter for > 30 miles< to be Ok to See, and Do not see. By accident I applied that filter to my map and it was brilliance!


            Thank you!