6 Replies Latest reply on Sep 14, 2017 8:33 AM by Alastair Matheson

    Dynamically adjust map color range

    Alastair Matheson

      Hi,

       

      I am trying to set up a map that displays different values based on a filter. The filter switches between responses to different questions on a survey.The values are pre-aggregated because of the need to produce weighted standard errors and to protect confidentiality of responses.

       

      If I let Tableau use the min and max values, it creates an artificial sense of difference between regions that is not always reflective of reality. Instead, I would like to set the dynamically set the range of the color gradient based on the range of values for that question but expanding it beyond the min and max. Possibilities could be expanding the axis by a fixed amount below the minimum and above the maximum, expanding it using some estimate of the spread (e.g., 2 standard deviations), or by having fixed points depending on where the min/max falls (e.g., if the minimum in that range falls between 50 and 65%, set the scale to start at 50%).

       

      The attached workbook has some dummy data. So far I have tried a few options, including adapting this: Two Sequential Color Palettes on the Same Map: Coloring by a Dimension and a Measure | Drawing with Numbers , but none quite do what I need. My sense is there might be some way to do it with a second map but I could not see a way to get axes to synchronize like is possible with a bar chart. Another approach I've thought of is setting two tiny polygons up (maybe in the middle of Lake Washington) in the shapefile and attaching values to those to set the max and min. That would probably need to happen at the data aggregation stage though. I wanted to see if there was a Tableau-based solution first.

       

      Does anyone have other ideas to try?

       

      Thanks!

        • 1. Re: Dynamically adjust map color range
          Simon Runc

          hi Alistair,

           

          Have you thought about using this option?

           

           

          by using a Diverging pallet, you can set the Start/End/Center of the coloring range. You can also use this in conjunction with the "Stepped Colour"

           

           

          That might help.

          • 2. Re: Dynamically adjust map color range
            Alastair Matheson

            I have looked at diverging a little but that still requires manually setting the start and end points of the range, right? I basically need some dummy values to force Tableau to have a wider range, but the dummy values need to vary based on the filter selection.

            • 3. Re: Dynamically adjust map color range
              Simon Runc

              Yes I see what you mean...What about this?

               

               

              I've created one calculation to pick up the mid-point of any Indicator

               

              [Percent Range - MidPoint]

              {FIXED [Indicator]: MIN([Percent])}

              +

              (({FIXED [Indicator]: MAX([Percent])}

              -

              {FIXED [Indicator]: MIN([Percent])})/2)

               

              btw I feel there is a simplified version of this calculation...but late in the day here, so brain is running on fumes! (it works...so I stopped!)

               

              and then another calculation, which we use for colouring, which is the distance from the "Mid Point"...

               

              [Percent Colour - Distance from MidPoint]

              [Percent]

              -

              [Percent Range - MidPoint]

               

              We can then use this on the colour self, and set the range we want...

               

               

              This way you can choose "how far from a dynamic midpoint you want to distinguish by shade"

               

              There are also many variations (distance from average, SDs [as you've already mentioned]...etc.)

               

              Hope that works (and makes sense)

              • 4. Re: Dynamically adjust map color range
                Alastair Matheson

                Thanks. That gets me a lot of the way there. I set things up to work with the standard deviation so that manually inputting the range was less important (3 SDs either side of the mean seemed to hit the right balance) (see the Twomaps sheet).

                 

                The one major remaining issue is to display the actual percents that the range corresponds to rather than the deviation. Is there a simple way to do that?

                • 5. Re: Dynamically adjust map color range
                  Simon Runc

                  Excellent...yes that works really well

                   

                  So it terms of a legend which reflect the actual values...

                   

                  One way to do this is to set up the legend from another sheet. Below is the set up for the bar chart which will act as our legend.

                  Notice that;

                  the Std Dev From Mean is used as a Dimension...this means I get a mark [bar] for each unique value

                  The MIN 0.9 and 1 Dimension (which is set to not show header) is so the bars fill the entire screen

                  The Axis is also reversed

                  The Label is set up to display MIN and MAX

                   

                   

                  The really cool thing about making the legend from a sheet...is that we can set actions from the legend to the map...

                   

                  Highlight Legend.gif

                   

                  This is actually a really useful technique (and not really thought about doing it this way before)...I feel a blog coming on!

                  3 of 3 people found this helpful
                  • 6. Re: Dynamically adjust map color range
                    Alastair Matheson

                    Great idea. Thanks, that works really well.