Tableau error Type mismatch

The calculation contains errors

Can’t divide string values by float value

The field on the left of / is text, even if it looks like a number. Division needs numbers on both sides, so convert the text field first.

Updated · Checked on the xmetric engine

Which formula raises it, and what fixes it?

Raises the error
[Cost] / [Sales]
Tableau: Can’t divide string values by float value

The xmetric engine rejects it too.

Fixed
FLOAT([Cost]) / [Sales]

On each of the 3 example rows it returns:

RegionCostSalesResult
East8.520.50.41
West610.50.57
West2.55.50.45

Why it works. FLOAT() reads "8.5" as 8.5, so the division runs: 8.5 / 20.5 is about 0.41. Text that is not a number becomes null. If the field is an ID like Order ID, dividing it is probably not what you meant.

The 3 example rows
RegionCostSales
East8.520.5
West610.5
West2.55.5

What else raises this message?

  1. Raises it

    [Cost] / 100.0

    Fixed

    FLOAT([Cost]) / 100.0

    Dividing by a decimal number needs a number on the left too; convert the text column first.

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

  2. Raises it

    [Cost] / ([Sales] * 2)

    Fixed

    FLOAT([Cost]) / ([Sales] * 2)

    The right side is a decimal number here as well, so only the text side needs FLOAT.

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

Where does a text cost column come from?

Usually a currency symbol or thousands separators in the source, or a decimal comma such as 1.200,00. Clean them with REPLACE before FLOAT, or fix the type at the source.

Should I convert in the formula or in the data source?

In the data source when you can, once for every sheet. Converting in each formula repeats the work and the risk.

Where is this message documented?