Video | Tableau | Data visualisation | Analytics

The Index ( ) function in Tableau

The index function simply counts rows but there's more to it than meets the eye.

Part ofTableau Functions
Watch on YouTube
  • INDEX() counts rows and has no arguments; the quickest way to use it is to type it as an ad hoc calculation directly in a shelf
  • Because INDEX() returns as a measure (green) by default, set it to discrete to get clean row numbers as headers rather than a bar chart
  • Use Compute Using and the table calculation partition settings to control whether the count restarts within subcategories or runs down the whole table
  • Wrapping INDEX() inside RANK() reverses the count, letting you number rows from the bottom up
  • A practical date trick: rank an index counting from the bottom, then keep only values 1-6 to always show the most recent six months as data updates

INDEX() just counts rows in your data set, but its behaviour changes depending on whether it's discrete or continuous and how its partition is set — understanding this unlocks row numbering, custom sorting, and a handy trick for always showing only the most recent dates.

Demonstrated on a superstore-style sales data set with categories, subcategories and order dates. No special setup is required beyond a table with rows you want to number or rank.

The Breakdown
  • What INDEX() actually does 0:22

    INDEX() has no arguments and simply counts the rows in your data set. The quickest way to use it is to double-click into a shelf or the marks pane and type it directly as an ad hoc calculation rather than building a named calculated field.

  • Discrete vs continuous changes everything 2:45

    INDEX() returns as a measure (green) by default, which makes Tableau draw a bar chart instead of showing clean row numbers. Set it to discrete to turn it into a header, giving you a proper row-number column.

  • Repurpose the bar behaviour creatively 4:33

    Before switching to discrete, the automatic bar/circle chart that INDEX() produces can itself be useful — the further down the data set a row sits, the higher its value, so you can use that to visually separate or spread out marks for creative chart layouts.

  • Partitions control where the count restarts 6:07

    INDEX() counts according to a 'partition' — by default the whole table, but using Compute Using you can make the count restart within each subcategory (or other grouping) rather than running continuously down the table. Getting more granular partitions (e.g. nesting category inside subcategory) needs the table calculation's addressing/partitioning settings set deliberately, since simply changing the field order won't do it on its own.

  • Wrap it in RANK() to count backwards 9:24

    Wrapping INDEX() inside RANK() reverses the numbering, because RANK() sorts descending by default — so the largest row gets the top rank. This only works because of how RANK() treats its input; nesting functions like this can produce behaviour you wouldn't expect from either function alone.

  • Keep only the most recent N dates 11:02

    For a date field sorted with the most recent period at the bottom, wrap INDEX() in RANK() so the newest row becomes rank 1, then use 'keep only' on ranks 1 through however many periods you want. This stays reliable as new data arrives, unlike selecting fixed row numbers or trying to build an equivalent date filter.

  • Hide it once it's done its job 13:01

    Once the rank/index field is filtering the view correctly, you can hide its header or move it to the Detail shelf — it keeps working invisibly in the background because it's still part of the visualisation's context, so you don't need to display the numbers themselves.

Worth Knowing
  • Changing which field sits in front of another (e.g. reordering category and subcategory) doesn't automatically change the partition the count restarts on — you need to set Compute Using explicitly.
  • Getting index counts to restart correctly at nested levels of a hierarchy (e.g. by category while subcategory is also in view) requires manually setting the table calculation's addressing across multiple fields — Tim flags this as too complex to fully explain in this video.
  • INDEX() renders as a measure by default purely because it's a count, which causes confusing default bar charts until you set it to discrete.
Use It When

Reach for INDEX() whenever you need row numbers, custom sort-driven positioning, or — combined with RANK() — a self-maintaining way to keep only the most recent N periods in a view without relying on brittle date filters.

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
5 July 2026 at 09:41 · 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.