4 Replies Latest reply on Nov 16, 2016 3:38 PM by Amanda Lamb

# Calculate field based using parameters and table calculations

Hello, I'm still relatively new to Tableau, so please forgive me if this is a simple question and I am missing something. Here is what I would like to have happen:

When the bars are above the reference line (which is set at "1"), the bar changes color.

The complication

Normally, this would be a really simple calculated field (IF >1 THEN "More", ELSE "Less" END; move that field to "color" mark). But I can't get that to work because of the parameters and table calculations that create those bars.

The bars are based on the parameter "choose sentence". The parameter options are

• Prison
• Jail
• Probation
• Fine/Fee

The complication is that the bars are based off a series of table calculations. You can see how I learned (via this community) to create those calculations in this forum discussion. The calculations require that I

1. Create a "grand total" for all sentenced cases (sum prison + jail + probation + fine/fee, roughly)
2. Create a "rate" for each sentence bucket (sum prison / grand total sentenced cases)
3. Calculate a relative rate by dividing the rate of people of color with the rate for white people.

The results look something like this (this one is for jail bookings):

This gets me the "relative rate of disparity" in sentencing. In the screenshot above, for instance, black defendants were 1.34 times more likely than white defendants to be sentenced to prison in 2014.

Back to the question: How can I get those bars to change color? I've attached this sheet of the project, if that helps.

• ###### 1. Re: Calculate field based using parameters and table calculations

Hey Amanda,

IF >1 THEN "More", ELSE "Less" END; move that field to "color" mark

I used this calculation applied to color:

IF [Chose Sentence Field] > 1 THEN "more" ELSE "less" END

And it produced this:

Best,

-Chris Chalmers

• ###### 2. Re: Calculate field based using parameters and table calculations

That is exactly what I want it to do. I've done exactly that and I don't understand why it won't work.

But then, here's "Prison"

"Jail"

"Probation"

And so on. I don't fully understand what is going on...

• ###### 3. Re: Calculate field based using parameters and table calculations

Interesting, I see that behavior on my end too if I use the calculation editor. To fix it try using an adhoc calculation, i.e. type the calculation directly into the shelf. I'm not sure why the behavior differs.

-Chris Chalmers

• ###### 4. Re: Calculate field based using parameters and table calculations

I still cannot get this to work, unfortunately. I do not know why...

But thank you for trying to help!