Video | Tableau | Data visualisation | Analytics

What is the Window function in Tableau? Tableau Functions

The window is just an invisible box moving through your table, and once you understand the coordinates you control exactly what it aggregates.

Part ofTableau Functions
Watch on YouTube
  • The window in any WINDOW_ function is defined by coordinates at the end of the expression, where 0 is the current row, FIRST is the start and LAST is the end, and everything between is aggregated.
  • The aggregation type (sum, average, etc.) is separate from the expression inside it — you can run WINDOW_AVG over a SUM([Sales]) for compound calculations.
  • Direction settings like table across, table down and table across then down dramatically change which cells fall inside the window.
  • Using pane across then down can force Tableau to scaffold data into empty cells, producing misleading results you almost never want.
  • Built-in quick table calculations such as moving averages are just window functions Tableau writes for you, and you can drag them out to reuse as calculations.

The window function in Tableau is essentially an invisible box that moves through your table aggregating whatever's inside it, and once you understand how its coordinates and direction work, you can control exactly what gets calculated in every cell.

Tim builds a simple crosstab of sales by subcategory and year in Superstore data, then writes WINDOW_SUM calculations against it to reveal how the function actually behaves.

The Breakdown
  1. Build a simple table first 0:31

    Set up a basic crosstab (Tim uses subcategory in rows, a date in columns, with a partition field in front) before writing any window calculation, so you can see how the aggregation moves across real cells.

  2. Write WINDOW_SUM and nest an aggregation inside it 2:47

    Any WINDOW_ function needs an aggregated expression inside it, such as SUM([Sales]) — the outer function (sum, average, etc.) is separate from and can differ from the aggregation inside it, so you can nest a WINDOW_AVG around a SUM for compound calculations.

  3. Understand default direction and use the Summary card to check it 4:53

    With no coordinates specified, the window defaults to a direction (e.g. table across) and totals every cell in that direction identically in each row; the Summary/calculator tool lets you click cells to confirm exactly what's being summed.

  4. Change direction to reshape the whole calculation 8:20

    Switching direction — table down, table across, table across then down — changes which cells fall inside the window without touching the formula itself; this is one of the most common levers to reach for once you understand the default behaviour.

  5. Define the window's size with FIRST, LAST and zero 9:46

    The two coordinates at the end of a WINDOW_ expression set the window's start and end: 0 means the current row, FIRST means the start of the partition, LAST means the end, and everything between is aggregated — this is the core mechanic the rest of the video builds on.

  6. Swap in other aggregations and reverse direction with FIRST 14:30

    You can drop in WINDOW_AVG (or others) in place of WINDOW_SUM without changing the coordinate logic; using FIRST instead of LAST at a given position flips which end of the table the window anchors to and reverses the running direction.

  7. Use numeric offsets for tight, moving windows 18:37

    Instead of FIRST/LAST, you can use numbers like 0 and 1 to define a small window (e.g. current row plus the next) that slides through the table row by row — useful for things like short moving averages.

  8. Avoid pane across then down — it scaffolds phantom data 21:09

    Table across then down is a legitimate direction but gets confusing to trace by hand; pane across then down is different and dangerous because it forces Tableau to scaffold in empty cells for categories with no data, producing misleading totals you almost never actually want.

Worth Knowing
  • A window function works with essentially any aggregation — sum, average, count, min, max, median, standard deviation — so the same coordinate logic applies whatever aggregation you choose.
  • Changing the last (right-hand) coordinate number means you need to re-check the bottom of the table, since Tableau can throw a null/error if the window tries to reference a row that doesn't exist.
  • Quick table calculations like moving averages are just window functions Tableau writes for you behind the scenes — you can double-click into them to see the actual WINDOW_ syntax and drag it out as a reusable calculation.
  • Coordinates can be written multiple ways (0,0 or FIRST,0 or FIRST+1,0 etc.) — the video only introduces the basics, not every notation.
Use It When

Reach for this whenever a built-in table calculation (running total, moving average, percent of total) doesn't quite do what you need and you have to hand-write the aggregation logic yourself, or when you want to understand what a quick table calculation is actually doing under the hood.

How this Rollup was made provenance & method

A Rollup is drafted by AI from the video's transcript, then reviewed and edited by Tim. Everything used to produce this one is listed below — the model, the exact prompt, and the source video — so the process is transparent and reproducible.

Transcription
On-device — NVIDIA Parakeet v3 for recent videos, OpenAI Whisper large-v3 for earlier ones. The transcript never leaves the machine or gets published.
Drafting
Claude Sonnet 5 in the cloud, from that transcript.
Prompt
The exact Rollup prompt (v2) — the full system prompt, unedited.
Source video
Watch on YouTube
Drafted
5 July 2026 at 09:38
Reviewed & edited
11 July 2026 at 13:40 · by Tim Ngwena

Model + prompt + video is everything you'd need to recreate a Rollup like this yourself. The one thing we don't share is the transcript.

Rights. The video and its transcript are the property of TN Media Ltd. Unauthorised use or download is prohibited. © TN Media Ltd.