dimanche 29 novembre 2015

if statement function for 1 value but for more than 1 validation

i have some problem when i created a calculated field in tableau.

lets say i have this "City" variable with these kind of data: 1 2 3 4 5 6 7 8

i want to make validate this number into if 1-4 become Region A, 5-8 become Region B and 1-8 is National.

this is my calculated filed code

if [City]=1 or [City]=2 or [City]=3 or [City]=4 THEN "Region A"
elseif [City]=5 or [City]=6 or [City]=7 or [City]=8 THEN "Region B"
elseif [City]=1 or [City]=2 or [City]=3 or [City]=4 or [City]=5 or [City]=6 or 
[City]=7 or [City]=8 THEN "National"
END

but after i created this calculated field, only "Region A" and "Region B" and "Null" showed. My thought is maybe that code is overlapping on Region with National (or is not?).

How can i solve this? and where this null come from when my data only have the range from 1-8?

Thank you

Aucun commentaire:

Enregistrer un commentaire