Tableau error Type mismatch

The calculation contains errors

expected type float found boolean

CASE compares one field against each WHEN value. Your CASE field is a number, but the WHEN holds a test that returns TRUE or FALSE, so the types clash. Use IF for tests.

Updated · Checked on the xmetric engine

Which formula raises it, and what fixes it?

Raises the error
CASE [Sales]
WHEN [Category] = 'Tech' THEN 1.00
ELSE 0.00
END
Tableau: expected type float found boolean

The xmetric engine rejects it too.

Fixed
IF [Category] = 'Tech' THEN 1.00 ELSE 0.00 END

On each of the 3 example rows it returns:

RegionSalesCategoryResult
East20.5Tech1
West10.5Office0
West5.5Tech1

Why it works. IF evaluates the test directly. CASE only fits when you match one field against fixed values, for example CASE [Category] WHEN 'Tech' THEN 1.00 ELSE 0.00 END.

The 3 example rows
RegionSalesCategory
East20.5Tech
West10.5Office
West5.5Tech

What else raises this message?

  1. Raises it

    CASE [Sales]
    WHEN [Sales] > 100 THEN 'Big'
    ELSE 'Small'
    END

    Fixed

    IF [Sales] > 100 THEN 'Big' ELSE 'Small' END

    CASE compares one value with fixed values. For conditions, use IF.

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

When should I use CASE instead of IF?

Use CASE to map exact values (CASE [Region] WHEN 'East' THEN ... ). Use IF for anything with a comparison, a range or AND/OR.

Is CASE faster than IF?

It can be slightly, for long lists of exact values, but the difference rarely matters. Write the one that reads better.

Where is this message documented?