# 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 Reports article.

## Tableau Aggregate Functions

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

### Tableau Sum Function

The Tableau Sum function is used to find the Sum of records in a column and the basic syntax of this Sum 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.

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 aggregate calculation window is showing the suggestions.

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 aggregated Sum is

`SUM([SalesAmount])`

Now you can see our newly created Sum calculated filed

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 Avg Function

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

`AVG(Expression)`

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

`AVG([SalesAmount])`

Click OK to close the window

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

### Tableau MIN Function

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

`MIN(Expression)`

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

`MIN([SalesAmount])`

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

The Tableau MIN aggregate 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.

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

### Tableau MAX Function

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

`MAX(Expression)`

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

`MAX([SalesAmount])`

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

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.

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

### VAR

The Tableau VAR is an aggregate function, which is used to find the Variance of the sample population. The syntax of this 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

### VARP

The Tableau VARP function is useful to find the Variance of the entire population and the syntax of VARP aggregate is :

`VARP(Expression)`

Let me create a new field called Sales_PVariance.

`VARP([SalesAmount])`

Click OK to close the window

Let me add those two variances to the column chart

### STDEV

The STDEV is one of the aggregate functions in tableau, which is useful to find the standard deviation of the sample population. The syntax of this 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

### STDEVP

This method is for finding the standard deviation of the entire population and the syntax of this STDEVP is:

`STDEVP(Expression)`

Let me create a new field called Sales_StdDeviationP.

`STDEVP([SalesAmount])`

Let me add those two standard deviations to the column chart

### Tableau COUNT Function

The COUNT function is one of the Tableau aggregate function, which is useful to find the number of not null values. The syntax of this 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.

Let me add this to Tableau Count Row Field.