期望 'End' 匹配字符 0 处的 'if'?

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

此代码出错。不知道哪里出了问题。它给我错误“预期 'End' 匹配字符 0 处的 'if'。”顺便说一下,这是在 Tableau 中,我正在尝试为数据制作 KPI。

您的 ELSE 应该是 ELSEIF。或者您应该删除 AVG([Covid Death Rate Cleaned]) <= 175 THEN,它只对 ELSEIF 有意义,对 ELSE 不有意义。

ELSE 应该满足所有剩余的不满足条件,因此它不应像 ELSEIF 那样仅限于特定条件。 因此,如果您想使用 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

##或者如果必须指定条件,您可以使用 ELSEIF

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