5 Replies Latest reply on Dec 12, 2013 10:24 AM by Matt Lutton

# Between calculated field?

Does anyone know how to create a calculated field with between, I am stumped. Any help would be appreciated.

Trying to create a parameter based on this formula and analyze by color. I tried to do this

if [capacity]> 300 then "Large"

elseif [Capacity]>= 200 then "Medium"

elseif [Capacity]>= 100 then "Small"

else "none"

end

what i really want to see is :

if capacity is between 50-150 then "small"

elseif capacity is between 151-250 then "medium"

elseif  250-300+ then "large"

else "none"

end

Can i achieve this in tableau?

Thanks much

K

• ###### 1. Re: Between calculated field?

Something like this may work--you may need to aggregate the Capacity fields, if it makes sense to do that.  In that case, you'd just wrap each Capacity field in SUM(), like IF SUM([Capacity])>50... etc

if [Capacity] > 50 AND [Capacity] <=150 then "Small"

elseif  [Capacity] > 151 AND  [Capacity] <= 250 then "Medium"

elseif   [Capacity] > 250 then "Large"

else "none"

end

There may be more efficient ways to write this calculation, but I believe this will work.

• ###### 2. Re: Between calculated field?

You have to AND two comparisons

if  capacity >50  AND capacity <= 150 then  etc,...

Michel

1 of 1 people found this helpful
• ###### 3. Re: Between calculated field?

The capacity fields are pre-calculated in the data set and are count distinct or count. Either ways yours or Michel's formula works perfectly. I am able to segregate the capacity into different brackets.

Thanks a bunch Matthew!

• ###### 4. Re: Between calculated field?

Thanks Michel it works.

• ###### 5. Re: Between calculated field?

No problem at all.