Tableau error Syntax
Expected 'END' to match 'IF'
You wrote ELSE IF with a space. Tableau reads that as ELSE followed by a new IF, and that inner IF needs its own END. Write ELSEIF as one word.
Which formula raises it, and what fixes it?
IF [Profit] <= -1 THEN 1
ELSE IF [Profit] > 0 THEN 2
ELSE 3
ENDThe xmetric engine rejects it too.
IF [Profit] <= -1 THEN 1
ELSEIF [Profit] > 0 THEN 2
ELSE 3
ENDOn each of the 3 example rows it returns:
| Region | Profit | Result |
|---|---|---|
| East | 4 | 2 |
| West | −2 | 1 |
| West | 1 | 2 |
Why it works. ELSEIF continues the same IF, so one END closes everything. Nesting a real inner IF also works, but then it needs its own END: ... ELSE IF [Profit] > 0 THEN 2 ELSE 3 END END.
The 3 example rows
Region | Profit |
|---|---|
| East | 4 |
| West | -2 |
| West | 1 |
What else raises this message?
Raises it
IF [Profit] > 100 THEN 'High' ELSE IF [Profit] > 0 THEN 'Low' ENDFixed
IF [Profit] > 100 THEN 'High' ELSEIF [Profit] > 0 THEN 'Low' ENDELSE IF with a space opens a new IF that needs its own END. ELSEIF continues the same one.
Checked on the xmetric engine: the first fails, the fix runs.
Raises it
IF [Profit] < 0 THEN 'Loss' ELSE IF [Profit] = 0 THEN 'Even' ELSE 'Gain' ENDFixed
IF [Profit] < 0 THEN 'Loss' ELSEIF [Profit] = 0 THEN 'Even' ELSE 'Gain' ENDThe same fix: one IF with ELSEIF, closed by one END.
Checked on the xmetric engine: the first fails, the fix runs.
Does my formula have this problem?
Paste your formula and run it on the example rows. It uses the fields [Region], [Profit]; rename yours to match.
Runs in your browser on the xmetric engine. Nothing is uploaded.
Which functions does this involve?
What do people ask about this error?
Is ELSE IF ever correct?
Yes, if you close both IFs: IF a THEN x ELSE IF b THEN y ELSE z END END. ELSEIF is shorter and harder to get wrong.
Does the order of ELSEIF branches matter?
Yes. Tableau returns the first branch that is true, so put the narrowest tests first.
Where is this message documented?
- Where the message is reported (forums.sqlteam.com) checked October 17, 2026