4 Replies Latest reply on Jul 6, 2016 7:01 AM by Michel Caissie

# Changing a center value of a diverging color set with a calculated field in tableau

I am trying to change a diverging color set's center value based on year. The data is normalized between 0 and 1, so the MIN and Max is from 0 to 1 for all years, but my average value changes year to year. Right now my center is auto set at .5, I would like to change the center of the the diverging color palette depending on which year is selected.

• ###### 1. Re: Changing a center value of a diverging color set with a calculated field in tableau

Michel Caissie I came across a post that you helped on. I have a similar problem and have been stuck for a few days. Any advice or direction? Thanks.

• ###### 2. Re: Changing a center value of a diverging color set with a calculated field in tableau

Brandon,

What I would try is first to compute the value per player-year using lod, something like

{INCLUDE [player],[year]:AVG([value])}

Next, if you  want this value to be at the center of a diverging palette you would need to slide the values so the AVG becomes 0.

So the calculation to put on your color shelf would be something like

[value] - {INCLUDE [player],[year]:AVG([value])}

This way the  value lower than the avg would be negative and get a color from the left  of the diverging palette , and the value above

the avg would be positive and get a color from the right  of the diverging palette.

Now if you want to have only light and dark blue colors, it could bring another problem. Because if you select a light blue for the left color of

the palette,  -.49 would be darker than  -.01. You may correct this by adjusting your color calculation with

if [value] - {INCLUDE [player],[year]:AVG([value])}  >  0 than [value] - {INCLUDE [player],[year]:AVG([value])}

else -.5  + ABS([value] - {INCLUDE [player],[year]:AVG([value])})

this way  -.49 would become  -.01 and  -.01  would become -.49  and the result should be similar to a  blue  sequential palette.

Michel

• ###### 3. Re: Changing a center value of a diverging color set with a calculated field in tableau

Thank you for your help, this seems to get me very close to what I have been trying to do. I am having trouble finding a way to check the box to include totals in the diverging color window. It does not give me the option for this. Any suggestions. Thanks again.

• ###### 4. Re: Changing a center value of a diverging color set with a calculated field in tableau

Did you first enable the Totals  in  Analysis-Totals-show columns grand total ?