Tableau provides various Table Functions to perform the calculation on entire visual data. They are FIRST, LAST, INDEX, RUNNING_SUM, RUNNING_AVG, WINDOW_SUM, WINDOW_VAR etc. In this article, we will show you, How to use Tableau Table Functions with examples.

To demonstrate these Tableau Table Functions we are going to use the below-shown data. As you can see, there are 15 records in this table.

Remember, this is an Excel Worksheet. So, Please refer Connecting to Excel Files article to understand the connection settings.

## Tableau Table Functions

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

### Tableau FIRST Function

The Tableau FIRST function returns values from 0 to -n. Syntax of this Tableau FIRST Function is:

FIRST()

To demonstrate these table functions, we have to use table calculation. In order to create a table calculation, please navigate to Analysis Tab and select **Create Calculated Field…** option as shown below.

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

Click OK to close this window

Or you can click Default Table calculation hyperlink to alter the default settings. Clicking that link will open following window.

Let me add this FIRST function field to existing table (by dragging a field to **Measures** Shelf). Please refer Create Table Report article to understand the process of creating a table

You can edit this table calculation by clicking the down arrow. Next, select **Edit Table Calculation** option from the context menu.

This will open a new window called Table calculation.

Use this window to change the calculation process. We already explained these properties in our previous article. So, please refer Table Calculations article to understand these functionalities.

### Tableau LAST Function

The Tableau LAST function will return numbers from n to 0. I mean, the last record as 0, and first record as n. The syntax of this Tableau the LAST Function is:

LAST()

Let me add this LAST field to **Measures** shelf

### Tableau INDEX Function

The Tableau INDEX function will return numbers from i to n. I mean, the first record as 1, and last record as n. The syntax of this Tableau INDEX Function is:

INDEX()

Let me add this INDEX field to **Measures** shelf

### Tableau RUNNING_AVG Function

The Tableau RUNNING_AVG function will calculate the running average of the table. The syntax of this Tableau RUNNING_AVG Function is:

RUNNING_AVG(Expression)

Below statement will calculate the running average of Sales column across the table.

RUNNING_AVG(SUM([Sales]))

Let me add this RUNNING_AVG field to **Measures** shelf.

Third record: (25 + 25 + 60) /3 = 36.667 = 37

### Tableau RUNNING_COUNT Function

The Tableau RUNNING_COUNT function will return the running count of the table. The syntax of this Tableau RUNNING_COUNT Function is:

RUNNING_COUNT(Expression)

Below statement will return the running count of Sales column.

RUNNING_COUNT(SUM([Sales]))

Let me add this RUNNING_COUNT field to **Measures** shelf.

### Tableau RUNNING_MAX Function

The Tableau RUNNING_MAX function will return the running maximum value. The syntax of this Tableau RUNNING_MAX Function is:

RUNNING_MAX(Expression)

Below statement will return the running maximum value in a Sales column.

RUNNING_MAX(SUM([Sales]))

Let me add this RUNNING_MAX field to **Measures** shelf.

### Tableau RUNNING_MIN Function

The Tableau RUNNING_MIN function will return the running minimum value. Syntax of Tableau RUNNING_Min Function is:

RUNNING_MIN(Expression)

Below statement will return the running minimum value in a Sales column.

RUNNING_MIN(SUM([Sales]))

Let me add this RUNNING_MIN field to **Measures** shelf.

### Tableau RUNNING_SUM Function

The Tableau RUNNING_SUM function will calculate the running total. The syntax of this Tableau RUNNING_SUM Function is:

RUNNING_SUM(Expression)

Below statement will return the running maximum value in a Sales column.

RUNNING_SUM(SUM([Sales]))

Let me add this RUNNING_SUM field to **Measures** shelf.

Third record: (50 + 60) = 110

### Tableau SIZE Function

The Tableau SIZE function returns total records in a table or pane. The syntax of this Tableau SIZE Function is:

SIZE()

Let me add this SIZE field to **Measures** shelf. As you can see, we are changed the default calculation to display the size based on Occupation

### Tableau TOTAL Function

The Tableau TOTAL function will return the complete total in a window. The syntax of this Tableau Total Function is:

TOTAL(Expression)

Below statement will return the total sales amount in this table. i.e., 25 + 25 + 60 + 24 +….. + 2320

TOTAL(SUM([Sales]))

Let me add this TOTAL field to **Measures** shelf.

This time we are computing using Occupation. It means the total function will sum based on occupation.

First set: 25 + 25 + 60 + 24 = 133

### Tableau WINDOW_AVG Function

The Tableau WINDOW_AVG function will calculate the average of the data in a table. The syntax of this Tableau WINDOW_AVG Function is:

WINDOW_AVG(Expression, start_point, end_point)

Below statement will calculate the average of Total Sales.

WINDOW_AVG(SUM([Sales]), FIRST(), LAST())

Let me add this WINDOW_AVG field to **Measures** shelf.

Here, the Sum of 15 records is 28, 794.

Average = 28,794/15 = 1919.6 = 1920

This time we are calculating average from first record to Last – 12 (means 15 – 12). i.e., first record to third record

Window_Avg = 25 + 25 + 60 = 36.67 = 37

### Tableau WINDOW_MEDIAN Function

The Tableau WINDOW_MEDIAN function will calculate the median from start point to end in a table. The syntax of this Tableau WINDOW_MEDIAN Function is:

WINDOW_MEDIAN(Expression, start_point, end_point)

Below statement will calculate the median of Total Sales.

WINDOW_MEDIAN(SUM([Sales]), FIRST(), LAST())

Let me add this WINDOW_MEDIAN field to **Measures** shelf.

### Tableau WINDOW_MAX Function

The Tableau WINDOW_MAX function returns the Maximum value from start point to end in a table. The syntax of this Tableau WINDOW_MAX Function is:

WINDOW_MAX(Expression, start_point, end_point)

Below statement will find the minimum value from the first record to last – 8 (means, 15 – 8 = 7)

WINDOW_MAX(SUM([Sales]), FIRST(), LAST() - 8)

Let me add this WINDOW_MAX field to **Measures** shelf.

### Tableau WINDOW_MIN Function

The Tableau WINDOW_MIN function returns the Maximum value from start point to end in a table. The syntax of the Tableau WINDOW_MIN Function is:

WINDOW_MIN(Expression, start_point, end_point)

Below statement will find maximum value from first record + 4 to the last record

WINDOW_MAX(SUM([Sales]), FIRST(), LAST() - 8)

Let me add this WINDOW_MIN field to **Measures** shelf.

### Tableau WINDOW_SUM Function

The Tableau WINDOW_SUM function calculates the sum from start point to end point in a table. The syntax of this Tableau WINDOW_SUM Function is:

WINDOW_SUM(Expression, start_point, end_point)

Below statement will calculate the Total Sales from 11 to 15.

WINDOW_SUM(SUM([Sales]), FIRST(), LAST())

Let me add this WINDOW_SUM field to **Measures** shelf.

Sum from 11 to 15 = 3078 + 540 + 4320 + 699 + 2320 = 10957.

### Tableau WINDOW_VAR Function

The Tableau WINDOW_VAR function returns the variance of sample population from start point to end point in a table. The syntax of this Tableau WINDOW_VAR Function is:

WINDOW_VAR(Expression, start_point, end_point)

Below statement will calculate the variance from current row to the previous row.

WINDOW_VAR(SUM([Sales]), FIRST(), 0)

Let me add this WINDOW_VAR field to **Measures** shelf.

### Tableau WINDOW_VARP Function

The Tableau WINDOW_VARP function returns variance of the complete population from start point to end point in a table. The syntax of this Tableau WINDOW_VARP Function is:

WINDOW_VARP(Expression, start_point, end_point)

Below statement will calculate the variance from the third row to the previous row.

WINDOW_VARP(SUM([Sales]), FIRST()+ 2, 1)

Let me add this WINDOW_VARP field to **Measures** shelf.

### Tableau WINDOW_STDEV Function

The Tableau WINDOW_STDEV function returns standard deviation of sample population from start point to end point in a table. The syntax of this Tableau WINDOW_STDEV Function is:

WINDOW_STDEV(Expression, start_point, end_point)

Below statement will calculate the standard deviation from the second row to the current row.

WINDOW_STDEV(SUM([Sales]), FIRST()+ 1, 1)

Let me add this WINDOW_STDEV field to **Measures** shelf.

### Tableau WINDOW_STDEVP Function

The Tableau WINDOW_STDEVP function returns standard deviation of the complete population from start point to end point in a table. The syntax of the Tableau WINDOW_STDEVP Function is:

WINDOW_STDEVP(Expression, start_point, end_point)

Below statement will calculate the standard deviation.

WINDOW_STDEVP(SUM([Sales]), FIRST()+ 4, 2)

Let me add this WINDOW_STDEVP field to **Measures** shelf.

### Tableau WINDOW_PERCENTILE Function

The Tableau WINDOW_PERCENTILE function returns specified percentile from start point to end point in a table. The syntax of Tableau WINDOW_PERCENTILE Function is:

WINDOW_PERCENTILE(Expression, percentile, start_point, end_point)

Below statement will calculate the 25% percentile from previous two rows to the current row.

WINDOW_STDEVP(SUM([Sales]), FIRST()+ 4, 2)

Let me add this WINDOW_PERCENTILE field to **Measures** shelf.

### Tableau WINDOW_CORR Function

The Tableau WINDOW_CORR function returns correlation between two measures from start point to end point in a table. The syntax of Tableau WINDOW_CORR Function is:

WINDOW_CORR(Expression1, Expression2, start_point, end_point)

Below statement will find the correlation between total cost and sales amount from the previous three rows to the current row.

WINDOW_CORR(SUM([Total Cost]), SUM([SalesAmount]), -3, 2)

Let me add this WINDOW_CORR field to **Measures** shelf.

### Tableau WINDOW_COVAR Function

The Tableau WINDOW_COVAR function returns covariance of sample population from start point to end point in a table. The syntax of the Tableau WINDOW_COVAR Function is:

WINDOW_COVAR(Expression1, Expression2, start_point, end_point)

Below statement will find the sample covariance between total cost and sales amount from previous three rows to current row.

WINDOW_COVAR(SUM([Total Cost]), SUM([SalesAmount]), -3, 0)

Let me add this WINDOW_COVARP field to **Measures** shelf.

### Tableau WINDOW_COVARP Function

The Tableau WINDOW_COVARP function returns total population covariance from start point to end point in a table. The syntax of the Tableau WINDOW_COVARP Function is:

WINDOW_COVARP(Expression1, Expression2, start_point, end_point)

Below statement will find the population covariance between total cost and sales amount from previous two rows to current row.

WINDOW_COVARP(SUM([Total Cost]), SUM([SalesAmount]), -2, 0)

Let me add this WINDOW_COVARP field to **Measures** shelf.