When I was building dashboards in Tableau for sales reporting, I faced an issue where the dataset didn’t always contain the exact fields I needed in the view. For example, sales amounts were there, but no profit margins were displayed. For these out-of-the-box values, we need to create calculated fields.
In Tableau, calculated fields allow us to create new columns or measures by using formulas, logic, and functions on an existing dataset.
In this Tableau tutorial, I will explain how to create calculated fields in Tableau and what their use is in creating chart views.
Create a Calculated Field in Tableau
In Tableau, there are two ways to create a calculated field, which are mentioned below.
- In the Navigation bar, click Analysis tab -> Create Calculated Field.

- Another option to create a calculated field is from the Data pane. In the Data pane, click on the dropdown near the search bar and select Create Calculated Field.

Using this approach, we can open the formula editor, in which we can define the calculated field.
Now, in the examples below, we will see different scenarios to create calculated fields in Tableau using the Superstore Datastore.
Example-1: Create a Calculated Field to Display Profit in Percentage
In this example, we will create a calculated field to show Profit Margin %, which shows the profit made per sale.
- To create a calculated field, right-click in the Data pane dropdown and select Create Calculated Field.

- Enter the calculated field label as Profit Margin, then enter the formula below and click OK.
SUM([Profit]) / SUM([Sales])- To create the chart view, add the calculated field Profit Margin to the Columns and Sub-Category to the Rows.
As of now, the calculation is in number format. To change it to a percentage, click on the “Profit Margin” axis and select Format.

- In the Data Pane, select Default -> Numbers -> Percentage. Now, we can see the calculated field values in percentage.

This way, we can create a simple calculated field to show the profit percentage of sales.
Example-2: Create Calculated Field Using IF THEN Logic
In this example, we will create a calculated field using the IF THEN conditionals. In this calculated field, we will categorise orders as High Profit or Low Profit depending on whether the profit is above $1000.
- To create a calculated field, click on the Analysis tab and select Create Calculated Field.

- Label the calculated field as Profit Category and enter the formula below.
IF [Profit] > 100 THEN "High Profit"
ELSE "Low Profit"
END- To create the chart view, add the Sub-Category to the Rows and Sales to the Columns.
- To categorise the data into “High Profit” and “Low Profit“, add the calculated field to the Colour card in the Marks section.

With this, we can view the data in two different colours, where the orange colour shows “Low Profit” and the blue colour shows “High Profit“.
This way, we can create a calculated field in Tableau using the IF-THEN conditionals.
Example-3: Create a Filter using Calculated Field
In this example, we will create a filter using the calculated field. Here, we will define the conditions in the formula that will return values based on conditions.
For example, we want to filter the customers whose total sales exceed $10,000. Now, follow the steps to filter records based on the conditions.
- Click on the Analysis tab and select Create Calculated field.
- First, we will create a calculation to get the customer sales using the formula below.
{ FIXED [Customer Name] : SUM([Sales]) }- Now, create another calculated field, Top Customers, and enter the formula below to get the sales of top customers.
IIF([Customer Total Sales] > 10000, "Top", "Others")- Drag the calculated field Top Customers to the Filter section and select Top, then OK.

- To create the chart view, drag the Calculated field Top Customer Sales to Columns, Customer Names to Rows and Sales to Text card.

Now, we can see the Sales for the top customer, whose sales exceed $100,000.
Other than this, we can also use the calculation fields in Tableau conditional formatting, Level of detail operations and creating groups or sets.
Conclusion
In this Tableau tutorial, we have learned how to create calculated fields in Tableau. In the above examples, we created calculations to display profit margins, categorising sales with IF-THEN logic, or filtering top customers using LOD calculations.
By following the above examples, you can create calculated fields tailored to different requirements, highlight trends, or group data into categories.
You may also like to read:
- Create Multiple Select Parameters in Tableau
- Use Context Filters in Tableau
- Create a Set in Tableau
- Create a Table in Tableau
I am Bijay Kumar, the founder of SalesforceFAQs.com. Having over 10 years of experience working in salesforce technologies for clients across the world (Canada, Australia, United States, United Kingdom, New Zealand, etc.). I am a certified salesforce administrator and expert with experience in developing salesforce applications and projects. My goal is to make it easy for people to learn and use salesforce technologies by providing simple and easy-to-understand solutions. Check out the complete profile on About us.