How to Create Calculated Fields in Tableau
You can create calculated fields in your Tableau visualization. Calculated fields are fields that you create that don’t already exist in your data source. These calculated fields are created using formulas that are often based on other fields. You create calculated fields in Tableau using formulas. You can include the following elements in a formula:

Fields: These consist of the existing fields in your data source and can include other calculated fields and sets. In formulas, fields appear in orange text.

Functions: These are builtin operations that can be performed on data, such as COUNT, DATETIME, SUM, FIND, and DAY. Functions appear as light blue text in formulas.

Operators: These include the standard mathematical operators like +, –, and *. Operators show up as black text in formulas.

Parameters: These are placeholder variables that you can use in a formula so that the actual value is specified at runtime. Parameters appear as purple text in formulas.

Comments: You can add comments to your formulas to provide a level of documentation. Comments show up as green text in formulas. Items you enter after two forward slash marks are considered comments.
You can create quite complex calculated fields, but for this example, let’s have a look at creating something simple — a Profit Ratio field that’s the result of dividing the sum of the profit measure by the sum of the sales measure. Here’s what you need to do:

After you’ve connected to your data source in Tableau, open a worksheet.
You can use an existing worksheet or a new worksheet.

Click the down arrow to the right of the Dimensions header and choose Create Calculated Field from the popup menu that appears.