top of page

Welcome
to NumpyNinja Blogs

NumpyNinja: Blogs. Demystifying Tech,

One Blog at a Time.
Millions of views. 

Tableau Window Functions & Navigation Functions Made Simple: SUM, AVG, MAX , PERCENTILE , LOOKUP, INDEX, FIRST, LAST

What if you want to compare totals across rows or rank values without writing complex formulas? That’s exactly where window functions in Tableau comes in.


Window functions helps to perform calculations across range of rows in the view. It helps to compare one row to others, show running totals or moving averages. Window functions are powerful because they allow us to calculate values across range of rows without changing the structure of our view.


Why Use Window Functions?


  • Helps to Analyze Trends across rows to compute things like Rolling sums, Period-over-period comparisons.

  • To Compare values within a group Example( Sales vs Max sales in region)

  • To create dynamic metrics since they calculate values based on the current view , not on fixed data.


WINDOW Aggregation Functions (SUM, AVG, MAX, PERCENTILE)


Window Aggregation functions helps to perform calculation across the set of table rows. These functions provide perfect insight for running totals, moving averages , benchmarks and statistical analysis.


  1. WINDOW_SUM: Gives Sum of all the values in the window.


Syntax:

WINDOW_SUM(expression, [start], [end])

Example:

WINDOW_SUM(SUM([Sales]))

The below table shows the total sales across all cities using WINDOW_SUM.

 











Note: Tableau requires an aggregate inside window functions.


WINDOW_SUM([Sales]) since [Sales] is row-level field

WINDOW_SUM(SUM([Sales])) SUM([Sales]) is an aggregate.


2. WINDOW_AVG: This function averages values across defined window of rows in the view.


Syntax:

WINDOW_AVG(expression, [start], [end])

Example:

WINDOW_AVG(SUM([SALES]), -1, 0)

The Table shows WINDOW_AVG function calculation using current and previous sales across the window.


0=Current row

-1=previous row

NULL=Entire partition


In the below example WINDOW_AVG for Mumbai shows average of Hyderabad and Mumbai.

WINDOW_AVG for Mumbai=85000+70000   =77500

                                                       2

If we Omit start and end, Tableau averages across the entire visible row. 
















  1. WINDOW_MAX:This Function finds the maximum sales and shows the same value for all the rows across window.


Syntax:

WINDOW_MAX(expression, [start], [end])

Example

WINDOW_MAX(SUM([SALES]))

 













Since the maximum sales is highest for Hyderabad which is repeated across all the rows.


  1. WINDOW PERCENTILE: The table calculation which returns the actual value at given percentile within the current window.


Syntax:

WINDOW_PERCENTILE(aggregate_expression, percentile)

Example:

WINDOW_PERCENTILE(SUM([Sales]),0.9)

 















Formula Tableau uses

Firstly Tableau sorts the values in ascending order.


30000,37000,70000,83000,85000


position=(N-1).P+1


Where N=Number of values

P=(percentile(0.5 for 50 percentile)


(5-1).0.9+1=4.6This means 90th percentile lies between 4th and 5th value


4th value=83000

5th value=85000


83000+0.6*(85000-83000)

83000+0.6*2000=84200 is the 90th percentile.


Function

What it Does

Simple Formula

Example Output

when to use

WINDOW_SUM()

Calculate Totals across the window

WINDOW_SUM(SUM([Sales]))

Total Sales for all visible Cities

Running totals, percent of totals, cumulative metrics

WINDOW_AVG()

Calculates average of measures across the window

WINDOW_AVG(SUM([SALES]), -1, 0)

Calculate average for current and previous month

Moving averages , smoothing trends

WINDOW_MAX()

Returns the highest value in the window

WINDOW_MAX(SUM([SALES]))

Highest Sales among all visible Cities.

Peak detection, performance comparison

WINDOW_PERCENTILE()

Returns nth percentile of values in the window.

WINDOW_PERCENTILE(SUM([Sales]),0.9)

90th percentile of sales as per cities

SLA analysis , outlier detection


Navigation Functions(LOOKUP, INDEX, FIRST, LAST)


Navigation Functions are table calculation functions helps to move across rows within the partition. It helps analyst to navigate through data dynamically and built interactive insight driven dashboards.


  1. LOOKUP(): Returns the value of an expression from a different row relative to current row.


Syntax:

LOOKUP(expression, offset)

Example:

LOOKUP(SUM([Sales]),-2)

 













Use Cases:


  • Used to compare month over month change

  • Compare current and previous row

  • Filter visible rows for window functions- Regular filters hide rows but do not remove them from the window so lookup function forces WINDOW functions to use only visible rows.


  1. INDEX(): It assigns a sequential number to each row.

Use case:

  • Ranking

  • Creating custom sort logic

  • Highlighting first or last N rows















  1. FIRST():Returns the number of row from the first row. 














  1. LAST():Returns the number of rows from the last row.

 
















Difference Between Navigation and Window Functions


Navigation Functions

  • Navigate row by row

  • Refer to relative position

  • Useful for comparisons and sequencing

  • Example: LOOKUP(), FIRST(), LAST(), INDEX()


Window Functions

  • Works on Range of rows

  • Return aggregated values over that window

  • Useful for benchmarking and trends

  • Example: WINDOW_MAX(), WINDOW_AVG(), RUNNING_SUM()


Performance Consideration


  • Table calculations are computed after the data is loaded.

  • There may be performance issues for large data sets

  • Prefer LOD when possible


While navigation and window functions are powerful, excessive use on large datasets can affect performance.


When to Use Navigation or Window Functions


  • Use LOD when calculation must be used across sheets

  • Avoid Table calculations when results are independent of view


Common Mistakes and Best practices

  • Missing Compute using configuration

  • Incorrect sorting

  • Using Table calculations with LOD incorrectly


Best practice examples:

  • Always verify results after changing dimension

  • Use meaningful names for calculated fields

  • Test with sample data


Conclusion:

Window functions helps us to look across multiple rows while navigation functions helps us to move rows and compare values.Together they make our analysis smarter and more flexible which helps in building meaningful insights in Tableau.


+1 (302) 200-8320

NumPy_Ninja_Logo (1).png

Numpy Ninja Inc. 8 The Grn Ste A Dover, DE 19901

© Copyright 2025 by Numpy Ninja Inc.

  • Twitter
  • LinkedIn
bottom of page