Tableau Table Functions

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.

Tableau Table Functions

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

To demonstrate these Tableau Table Functions, we use this table. Remember, this is an Excel Worksheet. So, Please refer Connecting to the Excel Files in Tableau.

Tableau Table Functions 1

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 the table calculation. To create a table calculation, please navigate to Analysis Tab and select Create Calculated Field… option.

Tableau Table Functions 2

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

Click OK to close this window

Tableau Table Functions 3

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

Tableau Table Functions 4

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

Tableau Table Functions 5

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

Tableau Table Functions 6

It will open a new window called Table calculation.

Tableau Table Functions 7

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

Tableau Table Functions 8

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 Table Functions 9

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 Table Functions 10

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)

The below statement calculates the running average of the Sales column across the table.

RUNNING_AVG(SUM([Sales]))

Let me add this RUNNING_AVG field to the Measures shelf.

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

Tableau Table Functions 11

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)

The below statement returns the running count of the Sales column.

RUNNING_COUNT(SUM([Sales]))

Let me add this RUNNING_COUNT field to the Measures shelf.

Tableau Table Functions 12

Tableau RUNNING_MAX Function

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

RUNNING_MAX(Expression)

Returns the maximum running value in a Sales column.

RUNNING_MAX(SUM([Sales]))

Let me add this RUNNING_MAX field to the Measures shelf.

Tableau Table Functions 13

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)

Returns the minimum running amount in a Sales column.

RUNNING_MIN(SUM([Sales]))

Let’s add the RUNNING_MIN field to the Measures shelf.

Tableau Table Functions 14

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)

Returns the running total of a Sales column.

RUNNING_SUM(SUM([Sales]))

Let’s add the RUNNING_SUM field to the Measures shelf.

Third record: (50 + 60) = 110

Tableau Table Functions 15

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 the Measures shelf. As you can see, we are changed the default calculation to display the size based on Occupation

Tableau Table Functions 16

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)

Returns the total sales amount in this table. i.e., 25 + 25 + 60 + 24 +….. + 2320

TOTAL(SUM([Sales]))

Let me add this TOTAL field to the Measures shelf.

Tableau Table Functions 17

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 Table Functions 18

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)

It calculates 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

Tableau Table Functions 19

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

Window_Avg = 25 + 25 + 60 = 36.67 = 37

Tableau Table Functions 20

Tableau WINDOW_MEDIAN Function

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

WINDOW_MEDIAN(Expression, start_point, end_point)

Calculate the median of Total Sales.

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

Let me add this WINDOW_MEDIAN field to the Measures shelf.

Tableau Table Functions 21

Tableau WINDOW_MAX Function

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

WINDOW_MAX(Expression, start_point, end_point)

Finds the maximum 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 the Measures shelf.

Tableau Table Functions 22

Tableau WINDOW_MIN Function

The Tableau WINDOW_MIN function returns the Minimum 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)

Finds the minimum value from first record + 4 to the last record

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

Let me add this WINDOW_MIN field to the Measures shelf.

Tableau Table Functions 23

Tableau WINDOW_SUM Function

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

WINDOW_SUM(Expression, start_point, end_point)

Calculate the Total Sales from 11 to 15.

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

Let me add this WINDOW_SUM field to the Measures shelf.

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

Tableau Table Functions 24

Tableau WINDOW_VAR Function

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

WINDOW_VAR(Expression, start_point, end_point)

Calculate the variance from the current row to the previous row.

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

Let me add this WINDOW_VAR field to the Measures shelf.

Tableau Table Functions 25

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)

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 Table Functions 26

Tableau WINDOW_STDEV Function

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

WINDOW_STDEV(Expression, start_point, end_point)

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 the Measures shelf.

Tableau Table Functions 27

Tableau WINDOW_STDEVP Function

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

WINDOW_STDEVP(Expression, start_point, end_point)

Calculates the standard deviation of the complete population.

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

Let me add this WINDOW_STDEVP field to the Measures shelf.

Tableau Table Functions 28

Tableau WINDOW_PERCENTILE Function

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

WINDOW_PERCENTILE(Expression, percentile, start_point, end_point)

Calculate the 25% percentile from the previous two rows to the current row.

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

Let me add this WINDOW_PERCENTILE field to the Measures shelf.

Tableau Table Functions 29

Tableau WINDOW_CORR Function

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

WINDOW_CORR(Expression1, Expression2, start_point, end_point)

Finds 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 Table Functions 30

Tableau WINDOW_COVAR Function

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

WINDOW_COVAR(Expression1, Expression2, start_point, end_point)

It finds the sample covariance between total cost and sales amount from the previous three rows to the current row.

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

Let me add this WINDOW_COVARP field to Measures shelf.

Tableau Table Functions 31

Tableau WINDOW_COVARP Function

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

WINDOW_COVARP(Expression1, Expression2, start_point, end_point)

It finds the population covariance between total cost and sales amount from the previous two rows to the current row.

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

Let me add this WINDOW_COVARP field to Measures shelf.

Tableau Table Functions 32