Tableau error Syntax

The calculation contains errors

Unterminated string

A text value starts with a quote mark but never ends with one. Tableau then reads everything after it as part of the text.

Updated · Checked on the xmetric engine

Which formula raises it, and what fixes it?

Raises the error
IF [Region] = 'East' OR [Region] = 'West' THEN "Coastal Region ELSE "Other Region"
END
Tableau: Unterminated string

The xmetric engine rejects it too.

Fixed
IF [Region] = 'East' OR [Region] = 'West' THEN "Coastal Region"
ELSE "Other Region"
END

On each of the 3 example rows it returns:

RegionResult
EastCoastal Region
WestCoastal Region
CentralOther Region

Why it works. Every text value needs a matching pair of quotes, either "..." or '...'. Do not mix them on one value. A field name has the same rule with [ and ].

The 3 example rows
Region
East
West
Central

What else raises this message?

  1. Raises it

    IF [Region] = 'East THEN 1 END

    Fixed

    IF [Region] = 'East' THEN 1 END

    Every string needs a closing quote of the same kind.

    Checked on the xmetric engine: the first fails, the fix runs.

  2. Raises it

    [Region] + "'s total

    Fixed

    [Region] + "'s total"

    An apostrophe inside double quotes is fine; the double quote still has to close.

    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]; 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?

How do I put an apostrophe inside a string?

Wrap the string in double quotes, "O'Brien", or double the apostrophe inside single quotes, 'O''Brien'.

Why does the error show up far from the real mistake?

Everything after an unclosed quote is read as text, so the parser only notices at the end of the formula.

Where is this message documented?