Search code examples
parameterstableau-apicalculated-field

Change Legend with Calculated field


I am new in tableau, I have some problems here: Is it possible to change the legend in chart with calculated field or choose with parameter? More detail I have a chart like picture I attached: enter image description here I want to make a parameter that have the data is some legend that I can choose, so when I choose A, the chart colour will change based on legend A, when I choose B, the chart colour will change based on legend B, etc. So please help me

I have no idea is it possible or not?


Solution

  • Let's see if I managed to understand the question correctly :) You want to change the graph/colors based on different fields. To do that:

    1. you need a string parameter listing the values you want to use. For example, Field A, Field B, etc

    2. create a calculated field to reference the parameter. Something like:

      CASE [PARAMETER] WHEN 'Field A' THEN [Field A] WHEN 'Field B' THEN [Field B] END

    3. Make sure to show the Parameter

    4. Add the calculated field from step 2) onto Colors in the Mark Shelf

    5. Try changing the values of your parameter The above assumes you have already built a graph you'd like to use. If not, do that first. Colors for each option could be changed once you select the field & edit the colors.