1 2 3 Previous Next 37 Replies Latest reply on Jun 29, 2018 5:43 AM by Vincent Tchong

    Distance Mapping with Radius Filter

    Sarah Nell

      Mapping for single points on a map and filtering within a specific mile radius.   I had a hard time finding what I needed exactly on the forums for the radius filter until I figured out a super easy way to do it.  Here's how I do my mapping along with the associated filter for distance within a specific radius.   No need for multiple sheets or formulas.

          

      Step 1

       

       

      To start with you need to make sure that you data haslongitude and latitude in it.  If it doesn’t, there are plenty of free resources out on the web that link zip codeto latitude and longitude.  It’ll be a general set of data, but it will still allow you to map what previously wasn’t capable of being mapped for distance.  

       

      Once you have your data set up for longitude and latitude –you can connect your worksheet or data source to Tableau.

       

      After you have connected to your data make sure that your latitude and longitude are showing in the number format (right click on measure data type) and then coded as actual geographic points. 

      Step 2

       

      Now that you have your latitude and longitude set up, it’s time to set up your parameters and calculated fields to map your distance. 

       

      1. Parameter– creating what you will pick to be your center point from which all distance will be mapped.  Mine is named  Branch Description.
        1. To create a parameter, you want to choose first, what will be your unique center point
          for calculating distance
          .   In this specific case, I have picked field offices, also called “branch unit
          description”.    Right click on what you have chosen and Create Parameter. 
        2. When creating your parameter you always want it to be a string parameter, which
          you can pick from a drop down if it hasn’t automatically popular.  Based on the field that I created a parameter
          from as well, it should have automatically made it into a list format for me as well.  Be sure to  name it something that references what you’re trying to accomplish, too.   Click on OK when finished.
      2. Identifier
        – a calculated field that will identify your center point as being a different value from all other points on the map. 
        1. Next you want to identify the branch you are picking from your Branch Description parameter
          as being different from all other points on the map
          .   This is a simple “if” “then” statement. 
          • Create a calculated field using  IF  [Business Unit Desc] == [Branch Description]
            THEN 1 ELSE 2 END
            1. Business Unit Description is the dimension used for my parameter. If that is what I have picked in the drop down parameter box, it will give that a value of 1.  All other values on the map are then given a value of 2.  This sets the ground work needed to differentiate points on the map from each other.
      3. Distance – a calculated field that is the actual formula to calculate the distance between your center point and all other points on your map via latitude and longitude.
        1. This is the part where you wish you would have paid attention during trigonometry in
          high school
          .   Create a calculated field with the following formula:
        2. ACOS((SIN(RADIANS(LOOKUP(AVG([Lat]), First())))
          * SIN(RADIANS(AVG([Lat]))) + COS(RADIANS(LOOKUP(AVG([Lat]), First()))) * COS(RADIANS(AVG([Lat]))) *
          COS(RADIANS(AVG([Long])) - RADIANS(LOOKUP(AVG([Long]), First()))) ))*3959

       

      The Lat and Long are the name of my fields in my excel data source for Latitude and Longitude.  

      1. Once you have the green check mark for go in the calculated box, you’re ready to build.            

         

      Step 3

       

      By having all of your calculated fields and parameters set it will help in the actual build process.  .

          

      1. Under Parameter, you want to right click your parameter and ‘show parameter control”. This will create a drop down box for you to pick from on your map.
      2. Drag your Lat and Long over to the shelf.  If it doesn’t create a map right off the bat, you  may want to make sure that they are
        set up as geographic longitude and latitude.
      3. Under dimensions, pick which dimension you used to create your parameter and drag it over to map.  It should map all of those points automatically.
      4. Drag your “identifier” over to color.  This is the calculated field you created in the last section to identify your unique points on the map.   Once you have dragged this over it’s important that you change your measure from sum to minimum.   You will need to do this every time you want to use your identifier, it should always be measured as minimum.
      5. Change the Mark from “automatic” to “shapes”.   This will allow the shape option to appear
        in your formatting shelf.   Once you have done that, drag identifier from your Measures over to shape.   Again – remember to change your measure from sum to minimum.
      6. You can do the same with size if you would like to have a different size for your shapes than the current ones that
        exist.   I prefer this for mine, to highlight where my center point is in comparison to the rest of the points on
        the map.  Just drag “identifier” over to the formatting shelf under “size”.  
      7. Lastly – you want to label your points on the map with your distance calculation.  Drag “distance” over to label. 
        It will not populate with distance right away.   You will need to click on it and ‘edit table calculation”.    Once you have clicked on edit table calculation you will want to choose the “advance” option.
        1. Once in advanced you want to make sure to click the radio button labeled “field” and pick the dimension that you built
          your parameters and formulas around your – in my case it’s my business office description.   Be sure to pick “minimum”
          for its value as well.
      8. This should cause your labels to show what the correct distance is between each point.  

       

       

       

      Step  4

          

      Radius Filters

       

      Radius Filters will help you to breakdown all the data you are seeing on your map and look at specific areas within a certain distance of your choosing.  You will follow many of the same steps that you followed up above for labeling distance.

          

      1. Drag Distance under “filters”.  At this point it will look kinda wonky, but don’t worry, it’ll get better.   Make sure that it has chosen “range of values” and click on OK.
      2. You are going to edit the table calculation The Exact Same Way That You did In Step 3.  
      3. Once you have edited the table calculation the “range of values” screen will pop up again.  This time it will show you your range of miles within your map.   For me, I want to see all points on the map within 200 miles of my center point.  So I will change the bottom value to “0” and the top range to “200”.   Click “Ok”.  Done!
      4. Add a Quick Filter so you can choose to show either a smaller radius or larger radius. 

       

      After some formatting changes, that is completely at your discretion, you should be able
      to pick any point on your map and have it change automatically to a 200  mile radius. 

        1 2 3 Previous Next