bigdogg99juherd
bigdogg99juherd

Reputation: 27

Expected 'End' to match 'if' at character 0?

IF AVG([Covid Death Rate Cleaned]) >= 275 THEN "Extremely high COVID death rate" 
ELSEIF AVG([Covid Death Rate Cleaned]) >= 226.3 THEN "High COVID death rate"
ELSEIF AVG([Covid Death Rate Cleaned]) <= 200 THEN "Low COVID death rate"
ELSE AVG([Covid Death Rate Cleaned]) <= 175 THEN "Extremely low COVID death rate" 
END

This code is giving the an error. Not sure what is wrong. It gives me the error "Expected 'End' to match 'if' at character 0." This is in Tableau by the way, I am trying to make a KPI for data.

Upvotes: 0

Views: 4370

Answers (2)

user2030776
user2030776

Reputation: 1

ELSE should cater to all remaining unsatisfied conditions so it should not be limited to specific conditions as you would ELSEIF. So to get rid of the error your code should look like this if you want to use ELSE:

IF AVG([Covid Death Rate Cleaned]) >= 275 THEN "Extremely high COVID death rate" 
ELSEIF AVG([Covid Death Rate Cleaned]) >= 226.3 THEN "High COVID death rate"
ELSEIF AVG([Covid Death Rate Cleaned]) <= 200 THEN "Low COVID death rate"
**ELSE** "Extremely low COVID death rate" 
END

##OR else you could use ELSEIF if you must specify the condition:

IF AVG([Covid Death Rate Cleaned]) >= 275 THEN "Extremely high COVID death rate" 
ELSEIF AVG([Covid Death Rate Cleaned]) >= 226.3 THEN "High COVID death rate"
ELSEIF AVG([Covid Death Rate Cleaned]) <= 200 THEN "Low COVID death rate"
**ELSEIF** AVG([Covid Death Rate Cleaned]) <= 175 THEN "Extremely low COVID death rate" 
END

Upvotes: 0

ysth
ysth

Reputation: 98388

Your ELSE should be ELSEIF. Or you should remove the AVG([Covid Death Rate Cleaned]) <= 175 THEN, which only makes sense with an ELSEIF, not an ELSE.

Upvotes: 2

Related Questions