Say I have city populations for each state / city in the united states. I want to mark each city with over 2 million population as a big city. then if a state contains a "big city", i want to mark that state as a "big state". I made a calculated field:
if Pop>2000000 then "big city" else "small city" end
This works fine.
Now when I try to make a calculated field for state I tried this:
if contains([big city],"big") then "big state" else "small state" end
This almost works, but I get multiple values for each state when I only want 1 value, either big state or small state. How do I stop tableau from creating multiple values?
You can try that with an approach involving two calculated fields.
Assuming that your big_city, small_city calculation is a calculated field named
City_Size
Now, the First Calculated field will assign a 1 or 0 to each row, depeding upon the value of
City_Size
. Name it asis_big_state
Now use this calculated field into another calculation, termed as
State_type
Edit : You may combine both of them into one :