Tableau error Type mismatch

The calculation contains errors

Cannot add string and float values

You used + to join text and a number. In Tableau + adds numbers or joins text, never both at once, so the decimal field has to become text first.

Updated · Checked on the xmetric engine

Which formula raises it, and what fixes it?

Raises the error
[Region] + ': ' + [Sales]
Tableau: Cannot add string and float values

The xmetric engine rejects it too.

Fixed
[Region] + ': ' + STR([Sales])

On each of the 3 example rows it returns:

RegionSalesResult
East20.5East: 20.5
West10.5West: 10.5
West5.5West: 5.5

Why it works. STR() turns 20.5 into "20.5", so every part is text and + joins them. If you meant to add numbers, the text field is the problem: convert it with FLOAT() instead.

The 3 example rows
RegionSales
East20.5
West10.5
West5.5

What else raises this message?

  1. Raises it

    [Sales] + ' USD'

    Fixed

    STR([Sales]) + ' USD'

    Text and numbers don't add; convert the number with STR first.

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

  2. Raises it

    [Region] + ROUND([Sales], 0)

    Fixed

    [Region] + ' ' + STR(ROUND([Sales], 0))

    ROUND still returns a number, so STR comes last.

    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]; 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 does my label show 1234.5 instead of a formatted amount?

STR doesn't apply number formatting. For a formatted label, put the number on Label and format the field, rather than building the text in the formula.

What if the number is NULL?

STR(NULL) is NULL, and text + NULL is NULL. Wrap it: STR(ZN([Sales])).

Where is this message documented?