What a calculated field does and when you need one

A calculated field in Tableau is a new column of data you create by writing a formula that combines or transforms information already in your spreadsheet. Instead of going back to Excel and adding a column there, you build it inside Tableau so the calculation happens automatically whenever you refresh your data.

You use calculated fields when you want to do something your original data does not already show: divide revenue by quantity to get price per unit, combine first name and last name into a single field, extract just the month from a date, or flag which sales exceeded your target. The formula lives in Tableau, not in your source file, so your original spreadsheet stays unchanged.

The most common reason to create one is that you need to group or filter by something that does not exist as its own column yet. If your data has a "Date" field but you want to chart by quarter, a calculated field extracts the quarter. If you have "Sales" and "Cost" as separate columns but need to show profit on every row, a calculated field subtracts one from the other.

Key Takeaways

  • Open the Data pane on the left, right-click in the empty space below your field names, and select "Create Calculated Field" to start a new formula.
  • Write formulas using Tableau's function library—basic math like SUM([Sales]) / [Quantity] or text functions like LEFT([Name], 5) to grab the first five characters.
  • Test your formula by clicking the checkmark; Tableau tells you if the syntax is wrong before you save it.
  • Once saved, your calculated field appears in the Data pane and works like any other column—you can drag it to rows, columns, or filters.
  • Calculated fields update automatically when your source data changes, so you do not have to rebuild them.

Opening the calculated field dialog and naming your field

Start by opening your workbook in Tableau Desktop. On the left side, you will see the Data pane listing all the fields from your spreadsheet. Right-click in the empty gray space below the last field name and select "Create Calculated Field" from the menu that appears.

A dialog box opens with two text boxes: one for the field name at the top and a larger one below for the formula itself. Type a clear name that describes what the field will contain—something like "Profit," "Customer Full Name," or "Sales by Quarter." Avoid spaces and special characters; use underscores or camelCase instead (for example, Customer_Full_Name or CustomerFullName).

Once you have entered the name, click in the formula box and start typing your calculation. As you type, Tableau shows you a list of available functions and field names you can use. Click on any suggestion to insert it, or keep typing to write the formula yourself.

Writing formulas using Tableau functions

Tableau formulas follow a pattern: you write a function name, then put the data you want to work with inside square brackets. The most basic formulas use math operators. To divide sales by quantity, you would write [Sales] / [Quantity]. To add two numbers together, write [Cost] + [Shipping]. To multiply, use an asterisk: [Price] * [Quantity].

For text, use functions like CONCAT() to join fields together. If you have a "First Name" field and a "Last Name" field and want to combine them with a space between, write CONCAT([First Name], " ", [Last Name]). The LEFT() function grabs characters from the left side of text: LEFT([Product Name], 3) pulls the first three letters. RIGHT() does the same from the right end.

For dates, use DATEPART() to extract a piece of a date. To get just the year from a date field, write DATEPART('year', [Order Date]). To get the quarter, write DATEPART('quarter', [Order Date]). For conditional logic—"if this is true, show this value, otherwise show that value"—use IF(). An example: IF([Sales] > 10000, "High", "Low") checks whether sales exceed 10,000 and labels it accordingly.

Testing and saving your formula

Before you save, click the checkmark button next to the formula box. Tableau checks whether your syntax is correct and tells you if something is wrong. If you see a red error message, read it carefully—it usually points to the exact problem, like a missing bracket or a field name spelled incorrectly.

Common mistakes include forgetting square brackets around field names, using the wrong function name, or mismatching parentheses. If the error message says "Unknown function," double-check the spelling. If it says "Unknown field," make sure the field name in your formula matches exactly what appears in the Data pane, including capitalization and spaces.

Once the checkmark turns green and no error appears, click OK to save the field. It now appears in your Data pane, usually in a section called "Custom Fields" or at the bottom of your field list. You can use it when ready in your visualization—drag it to rows, columns, filters, or any other area just like you would a field from your original data.

Using your calculated field in charts and filters

After you save a calculated field, it behaves exactly like any other field in Tableau. Drag it from the Data pane onto the Rows shelf to create a row for each value. Drag it to Columns to create columns. Drag it to the Filters area to show only rows that meet a condition—for example, filter to show only records where your "Profit" calculated field is greater than zero.

You can also use a calculated field in color, size, or label encoding. If you created a field that flags high-value customers, drag it to the Color shelf and Tableau will color-code your visualization based on that flag. If you created a field that calculates the percentage of a total, drag it to the Label shelf so the percentage appears on each bar or point.

Calculated fields also work in aggregations. If you drag a calculated field to Rows and it contains a number, Tableau automatically sums it by default. You can change this by right-clicking the field and selecting a different aggregation like Average, Count, or Max.

Editing and deleting calculated fields

To change a formula you have already created, right-click the calculated field name in the Data pane and select "Edit." The dialog opens again with your original formula. Make your changes and click OK to save. Any visualization using that field updates automatically with the new calculation.

If you no longer need a calculated field, right-click it and select "Delete." Tableau warns you if the field is currently in use on any sheet. You can delete it anyway, but any visualization using it will break until you remove the field from that sheet.

You can also duplicate a calculated field to use it as a starting point for a similar one. Right-click the field, select "Duplicate," and Tableau creates a copy with a new name. Edit the copy to create your variation without affecting the original.

Common calculated field examples for organizing data

If your spreadsheet has separate columns for first and last names but you want to sort or search by full name, create a calculated field with CONCAT([First Name], " ", [Last Name]). This gives you a single searchable field without changing your original data.

If you have a date field but your reports group by month or quarter, create fields like DATEPART('month', [Order Date]) or DATEPART('quarter', [Order Date]). This lets you filter and group by time periods without rebuilding your data source.

If you track both revenue and cost but need to see profit on every row, create [Revenue] - [Cost]. If you need a profit margin percentage, create ([Revenue] - [Cost]) / [Revenue] * 100. These fields update automatically whenever your source data refreshes.

To categorize continuous numbers into buckets—turning ages into age ranges or sales into tiers—use nested IF() statements: IF([Sales] >= 50000, "Enterprise", IF([Sales] >= 10000, "Mid-Market", "Small")). This creates a new text field that groups your data without modifying the original numbers.

Frequently Asked Questions

Can I use a calculated field inside another calculated field?

Yes. Once you save a calculated field, it appears in the Data pane and you can reference it in new formulas just like any original field. Write the formula name in square brackets: [Profit] / [Revenue] works if both Profit and Revenue are calculated fields. This is useful for building complex calculations step by step.

What happens to my calculated field when I refresh my data?

The formula stays the same and recalculates automatically against the new data. If you add new rows to your spreadsheet and refresh in Tableau, the calculated field applies to those new rows without any action from you. The field definition lives in your Tableau workbook, not in your source file.

Why does my formula show an error even though I think it is correct?

Check that field names are spelled exactly as they appear in the Data pane, including capitalization and spaces. Make sure every opening bracket has a closing bracket, and every opening parenthesis has a closing one. If you are using a function name, verify the spelling matches Tableau's function library—hover over the function suggestion to see the correct syntax.

Can I create a calculated field that counts rows or sums values across my entire dataset?

Yes, but the behavior depends on context. Use SUM([Field Name]) or COUNT() in a calculated field, and Tableau will aggregate it based on how you use it in your visualization. If you drag it to Rows, it sums or counts within each row group. If you want a grand total that never changes, use TOTAL(SUM([Field Name])) instead.

Do I need to save my workbook after creating a calculated field?

Calculated fields are saved to your workbook automatically when you click OK in the dialog. You should still save your workbook file to preserve any visualizations using the field, but the field definition itself is stored as soon as you create it.