Tableau Aggregate Functions

Tableau provides various Aggregate Functions, which helps you to perform aggregations such as calculating sum, avg, minimum, maximum etc. In this article, we will show you how to use Tableau Aggregate Functions with examples.

To demonstrate these Tableau Aggregate Functions, we are going to use the data source that we created in our previous article. So, Please visit Data Labels in Tableau Reports article.

Tableau Aggregate Functions

The following examples will show you the list of Aggregate Functions in Tableau.

Tableau Sum Function

The Tableau Sum function is used to find the Sum of records in a column. The basic syntax of this Tableau Sum Function is as shown below:

SUM(Expression)

To demonstrate these Tableau aggregate functions, we have to use the Calculated Field. Please navigate to Analysis Tab and select the Create Calculated Field… option to create a calculated field.

Tableau Aggregate Functions 1

Once you click on the Create Calculated Field… option, the following window will be opened. Here, we renamed the default calculation name as Sum_Of_Sales.

As you can see from the below screenshot, while I was typing, Tableau calculation window is showing the suggestions.

Tableau Aggregate Functions 2

For the demo purpose, we will calculate the Sum of Sales Amount. By clicking the OK button, a new field called Sum_Of_Sales will create. And the final Code of Tableau Sum is

SUM([SalesAmount])
Tableau Sum Function 3

Now you can see our newly created Tableau Sum calculated filed

Tableau Sum Function 4

Let me create a Bar Chart by dragging Country to Columns Shelf, Sum_Of_Sales (new calculated field) to Rows shelf, and Country to Colors shelf.

Tableau Sum Function 5

Tableau Avg Function

The Tableau Avg or average function is used to calculate the Average. The syntax of this Tableau AVG Function is as shown below:

AVG(Expression)

As you can see from the below screenshot, we are creating a new field (Sales Average) using Tableau function.

AVG([SalesAmount])

Click OK to close the window

Tableau Avg Function 6

Let me replace the Sum of Sales in Rows shelf with this Sales Average field.

Tableau AVG Function 7

Tableau MIN Function

The Tableau MIN function is an aggregate function in Tableau, which is used to find the minimum value. The syntax of this Tableau MIN Function is as shown below:

MIN(Expression)

As you can see from the below screenshot, we are creating a field called Minimum Sales.

MIN([SalesAmount])
Tableau MIN Function 8

Let me place the Minimum Sales in Rows shelf, and Color dimension in Columns Shelf.

Tableau MIN Function 10

The Tableau MIN function accepts two arguments. Use this to find the smallest between two numbers. Syntax is:

MIN(Expression1, Expression2)

Here, we created a new field, Minimum_Sales_Cost, to find the lowest value between the Sales Amount and Total Cost.

Tableau MIN Function 11

Let me add Minimum Sales_Cost, SalesAmount & Total Product Cost to the chart

Tableau MIN Function 12

Tableau MAX Function

The Tableau MAX function is used to find the maximum value. The syntax of this Tableau MAX is as shown below:

MAX(Expression)

You can see that we are creating a field called Maximum Sales.

MAX([SalesAmount])
Tableau MAX Function 13

Let me replace the Minimum Sales field in Rows shelf with the Maximum Sales field.

Tableau MAX Function 14

In Tableau, the MAX function accepts two arguments. Use this to find the largest among two numbers. Syntax is:

MAX(Expression 1, Expression 2)

Here, we created a new field, Maximum_Sales_By_Cost, to find the largest value among the Sales Amount and Total Product Cost.

Tableau MAX Function 15

Let me add Maximum Sales_By_Cost, SalesAmount, and Total Product Cost to the chart

Tableau MAX Function 16

Tableau VAR Function

The Tableau VAR function is an aggregate function in tableau, which is used to find the Variance of the sample population. The syntax of this Tableau VAR is as shown below:

VAR(Expression)

Here, we are creating a new field called Sales_Variance.

VAR([SalesAmount])

Click OK to close the window

Tableau VAR Function 17

Tableau VARP Function

The Tableau VARP function is used to find the Variance of the entire population. Tableau VARP Syntax :

VARP(Expression)

Let me create a new field called Sales_PVariance.

VARP([SalesAmount])

Click OK to close the window

Tableau VARP Function 18

Let me add those two variances to the column chart

Tableau VAR Function 19

Tableau STDEV Function

The Tableau STDEV function is one of the aggregate functions in tableau, which is used to find the standard deviation of the sample population. The syntax of this Tableau STDEV is as shown below:

STDEV(Expression)

Here, we are creating a new field called Sales_StdDeviation.

STDEV([SalesAmount])

Click OK to close the window

Tableau STDEV Function 20

Tableau STDEVP Function

The Tableau STDEVP function is for finding the standard deviation of the entire population. The syntax of this Tableau STDEVP is:

STDEVP(Expression)

Let me create a new field called Sales_StdDeviationP.

STDEVP([SalesAmount])
Tableau STDEVP Function 21

Let me add those two standard deviations to the column chart

Tableau Aggregate Functions 22

Tableau COUNT Function

The Tableau COUNT function is one of the Tableau aggregate function, which is used to find the number of not null values. The syntax of this Tableau COUNT is as shown below:

COUNT(Expression)

Here, we are creating a new field called Count_Orders.

COUNT([OrderQuantity])

Click OK to close the window

TIP: Use COUNTD function to get a distinct count.

Tableau COUNT Function 23

Let me add this to Tableau Count Row Field.

Tableau COUNT Function 24