DEV Community

Punitha
Punitha

Posted on

Calculated Fields in Tableau

What is a Calculated Field?

  • A Calculated Field is a custom field created using formulas to perform calculations on existing data.

Why Use Calculated Fields?

  • Create new measures.

  • Perform calculations.

  • Create categories.

  • Calculate Profit Ratio.

  • Calculate Growth Percentage.

How to Create a Calculated Field

Step 1

Go to:

Analysis
        ↓
Create Calculated Field
Enter fullscreen mode Exit fullscreen mode

Step 2

Enter a name.

Example:

Profit Ratio
Enter fullscreen mode Exit fullscreen mode

Step 3

Write Formula:

SUM([Profit]) / SUM([Sales])
Enter fullscreen mode Exit fullscreen mode

Click OK.

Example 1: Profit Ratio

Formula:

SUM([Profit]) / SUM([Sales])
Enter fullscreen mode Exit fullscreen mode

Example 2: Discount Category

Formula:

IF [Discount] > 0.20 THEN
"High Discount"
ELSE
"Low Discount"
END
Enter fullscreen mode Exit fullscreen mode

Types of Calculated Fields

   Type                              Example

Arithmetic                    Sales + Profit
Conditional                   IF-ELSE
Date                              YEAR(Order Date)
String                            UPPER(Name)
Aggregate                     SUM(Sales)
Logical                           AND, OR
Enter fullscreen mode Exit fullscreen mode

Parameter vs Calculated Field

Feature           Parameter                   Calculated Field

Purpose           User Input                      Formula
Created By    User                            Formula
Dynamic           Yes                             Yes
Uses              Filters, Switching              Calculations
Enter fullscreen mode Exit fullscreen mode

Top comments (0)