Tableau String to Number Conversion: The 3 Best Ways

How-to basics · Updated November 23, 2026

The quickest way to convert a string to a number in Tableau is to use the INT() function for whole numbers or FLOAT() for decimals, writing something like INT([StringField]) in a calculated field. Alternatively, you can right-click the field in the Data pane, select Change Data Type, and choose Number (whole) or Number (decimal)—but that only works if every value is already a valid number.

Why Tableau Doesn’t Auto-Convert Strings

Tableau treats data types strictly. When you connect to a text file, Excel, or a database, each column is assigned a type—string, number, date, or boolean. If a column contains mixed content like “123”, “12.5”, and “N/A”, Tableau will usually import it as a string to avoid losing the text. This is safe but annoying when you need to do math. The conversion functions exist precisely because you can’t mix types in a single calculation: SUM([StringField]) will fail with an error like “Cannot mix aggregate and non-aggregate” or simply show a red exclamation mark. Understanding that Tableau doesn’t guess—it requires explicit conversion—is the first step to solving the problem.

Using INT() and FLOAT() for Clean Values

The most reliable method is a calculated field. For whole numbers, create a calculated field with:

INT([StringField])

For decimals, use:

FLOAT([StringField])

If the string contains leading or trailing spaces, Tableau’s INT() and FLOAT() automatically trim them. For example, if your field contains ” 42 “, INT([StringField]) returns 42. However, if the string has non-numeric characters like commas or dollar signs, these functions will return NULL. For instance, INT("1,200") returns NULL, not 1200. You must clean the string first using REPLACE() or REGEXP_REPLACE() to remove unwanted characters before converting.

Handling Commas, Dollar Signs, and Percentages

Real-world data often looks like “$1,200.50” or “85%”. To convert these, you need to strip the non-numeric characters. For a currency string, use:

FLOAT(REPLACE(REPLACE([StringField], "$", ""), ",", ""))

This removes dollar signs and commas, then converts to a float. For percentages like “85%”, remove the percent sign and then divide by 100 if you need the decimal equivalent:

FLOAT(REPLACE([StringField], "%", "")) / 100

If your data has multiple currency symbols or unusual formats, consider using REGEXP_REPLACE() to extract only digits and decimal points:

FLOAT(REGEXP_REPLACE([StringField], "[^0-9.]", ""))

This pattern removes everything except digits and periods. Note that this will fail if the string uses a comma as the decimal separator (e.g., “1.200,50” in European formats). In that case, replace the comma with a period first.

When to Use the Data Pane Method

If your string field contains only numeric characters (no letters, no symbols), the simplest approach is to right-click the field in the Data pane, select Change Data Type, and pick Number (whole) or Number (decimal). This directly changes the field’s type without writing a formula. It works well for columns that were accidentally imported as strings, such as ZIP codes or IDs that were stored with leading zeros. However, if any value is non-numeric, Tableau will replace those values with NULL and you may lose data. Always check the field after changing the type to ensure no unexpected nulls appeared.

Common Pitfalls and Errors

  • Leading zeros disappear: If you convert a string like “00123” to a number, you get 123. If you need to preserve leading zeros, keep the field as a string.
  • Nulls from invalid strings: INT() and FLOAT() return NULL for any string that isn’t a valid number. Use IFNULL() or ZN() to handle them.
  • Decimal vs. whole: INT() truncates decimals (e.g., INT("12.7") returns 12), while FLOAT() preserves them. Choose based on your needs.
  • Aggregation errors: After converting, you may need to change the default aggregation in the view. Right-click the field and select Measure > Sum or Average.
  • Data source vs. calculated field: Changing the data type in the Data pane affects the entire field, while a calculated field creates a new field. The calculated field is safer because it doesn’t alter the original data.

Converting in a Data Prep Tool (Tableau Prep)

If you’re using Tableau Prep Builder, you can convert data types during cleaning. In the cleaning step, click the data type icon next to the field name and select the target type. For more control, use a calculated field in Prep with the same INT() or FLOAT() functions. Prep also has a Clean step that can remove punctuation automatically. The advantage of Prep is that you can preview the results before you export to Tableau Desktop, and you can save the cleaned data as a new file or extract.

Alternatives: String Functions and Regular Expressions

Sometimes you don’t need to convert the whole string—you need to extract a number from a longer string. For example, a field like “Order #12345” requires extracting “12345”. Use REGEXP_EXTRACT() to pull the number:

INT(REGEXP_EXTRACT([StringField], "(\d+)"))

This returns the first sequence of digits. If you need a decimal, use FLOAT() instead. Another approach is to use SPLIT() if the number is separated by a delimiter. For instance, if the string is “ID: 42”, you could do:

INT(TRIM(SPLIT([StringField], ":", 2)))

This splits on the colon and takes the second part, trims spaces, and converts to an integer. These methods give you flexibility when the string contains extra text.

Frequently Asked Questions

Why does my INT() formula return null?

The most common reason is that the string contains non-numeric characters like spaces, commas, or letters. INT() only accepts strings that are exactly a number, optionally with a leading minus sign. Use REGEXP_REPLACE() to strip unwanted characters, or use TRIM() to remove spaces. Also check for hidden characters like tabs or newline breaks.

Can I convert a string to a number without a calculated field?

Yes, you can change the data type directly in the Data pane by right-clicking the field and selecting Change Data Type. This works only if all values are numeric. If any value is non-numeric, those rows become null. For mixed data, a calculated field is safer.

What is the difference between INT() and FLOAT()?

INT() converts to an integer, truncating any decimal part. FLOAT() converts to a decimal number, preserving the fractional part. For example, INT("12.9") returns 12, while FLOAT("12.9") returns 12.9. Use FLOAT() when you need precise decimals.

How do I convert a string to a number in Tableau Prep?

In Tableau Prep, you can change the data type by clicking the data type icon in the cleaning step and selecting the desired type. For more complex conversions, create a calculated field using the same functions like INT() or FLOAT(). Prep also allows you to preview the results before outputting.

Does converting a string to a number affect performance?

Calculated fields that convert strings can slow down workbook performance if the underlying data is large, because Tableau must compute the conversion for every row. To improve performance, consider doing the conversion in a data prep tool or in the database query. Using extracts can also help, as the conversion is done once when the extract is created.

Related

Try it: the Date Difference Calculator: days, months, years and weekdays between two dates, with the DATEDIF formulas.

More in How-to basics

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.