2 Replies Latest reply on Jul 8, 2013 9:46 AM by Tj Claridge

    Chart & Legend color change based on metric field

    Rajini S

      Hi All,


      I have a requirement to display color in the chart & legend based on metric's % change difference to previous Month. I have two metric Sales & Discount and it should work as below

            - If I select Sales and color should display as Red-Green.

           - If I select Discount and color should display as Green-Red.


      I have attached the sample report and please let me know your idea.


      Thanks in Advance!!


        • 1. Re: Chart & Legend color change based on metric field
          Rajini S



          I have moved one more step now as I have taken duplicate sheet and added condition like below

          case [Select Metric]

          when 'Exports' then 'Green'

          when 'Imports' then 'Red'



          Changed the metric color to Metric 1(Green-->Red) and Metric 2(Red-->Green). This is displaying colors in Map what I expected, but Legend have issue.

          Both Map legends are display one legend is fine with data but another legend display Null which need to hide.


          Attached sample dashboard.

          Is there a possibilities to show or hide legends based on selected metric or change legend color based on selected metric ?




          • 2. Re: Chart & Legend color change based on metric field
            Tj Claridge

            Hey Rajini,


            We can approach issues in Tableau using different methods. I noticed you built two graphs when only one is required to get the visualization I believe you want. I tried a few attempts to get the key to hide when the secondary graph is shown but it always presents a null key.


            So I backed up and took a new approach...


            My approach:

            • Build one map
            • Made a custom calculation to make "exports" a negative number
            • Left "imports" as positive
            • Set color scale from -1 (red) to 1 (green) with 0=white
            • Left all your filters the same


            Check out the attached workbook as an example. Check out the new dashboard I created to see how I approached. Hopefully this will get you moving down the right path.


            Let us know if this was helpful or not.