How do I make a Calculated Field with a ‘Between’ formula in Tableau?
- Tableau FAQs
- December 13, 2018
In this example, we are trying to create a calculated field where if the number is greater than 50.5 then = “gold standard” which I have gotten to work… but then I also want if >5 but <50.5 (so between 5 and 50.5) = “Minimum standard”.
You can use the IF function to solve this problem. We have previously covered various use cases for the IF expression, and here we will look at another one. It is often required to calculate categories that must include a certain value and an interval. To implement this, you can use the following expression:
IF [OrderQty] > 50
THEN 'Gold standard'
ELSEIF [OrderQty] > 5 AND [OrderQty] < 50
THEN 'Minimum standard'
ELSE 'Other'
END
IF [OrderQty] > 50 – here we indicate the condition for determining the first category
THEN ‘Gold standard’ – if the condition is TRUE, then we show the Gold Standard
ELSEIF [OrderQty] > 5 AND [OrderQty] < 50 – then we use ELSEIF (this is a series of expressions) and specify a logical expression in it with an interval.
THEN ‘Minimum standard’ – if the previous expression is TRUE, then we show the Minimum Standard
ELSE ‘Other’ – everything else is categorized as Other
END – and end the expression
Up Next:
Read How do you run Distinct Sum or Total using COUNTD function in Tableau?