Tableau error Type mismatch

The calculation contains errors

Can't compare string and float values

Your field holds numbers, but Tableau reads it as text. Comparing text with a decimal like .80 is not allowed, so convert the field to a number first.

Updated · Checked on the xmetric engine

Which formula raises it, and what fixes it?

Raises the error
IF [Score] < .80 THEN 'Does Not Meet' ELSE 'Meets' END
Tableau: Can't compare string and float values

The xmetric engine rejects it too.

Fixed
IF FLOAT([Score]) < .80 THEN 'Does Not Meet'
ELSE 'Meets'
END

On each of the 3 example rows it returns:

RegionScoreResult
East0.92Meets
West0.78Does Not Meet
West0.85Meets

Why it works. FLOAT() turns the text "0.78" into the number 0.78, so the comparison works. A value that isn't a number becomes null and falls to the ELSE branch. To fix it everywhere, change the field's type to Number (decimal) in the data source.

The 3 example rows
RegionScore
East0.92
West0.78
West0.85

What else raises this message?

  1. Raises it

    IF [Score] = 1.0 THEN 'Perfect' END

    Fixed

    IF FLOAT([Score]) = 1.0 THEN 'Perfect' END

    Convert the text column once, with FLOAT, before comparing it to a decimal number.

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

  2. Raises it

    [Score] > 0.5

    Fixed

    FLOAT([Score]) > 0.5

    The same conversion works in a plain comparison used as a filter or a color.

    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], [Score]; 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?

Why is my number column text?

A column becomes text when some values aren't numbers: N/A, a percent sign, a thousands separator in another locale. Fix the field type in the data pane, or clean the values before FLOAT.

What does FLOAT return for values that aren't numbers?

NULL. Rows with N/A drop out of numeric comparisons instead of breaking the calculation.

Where is this message documented?