# The Index ( ) function in Tableau

> This is content from just-tim, the data-and-analytics channel by Tim Ngwena (formerly 'Tableau Tim'). Tim has 12+ years of hands-on BI experience and covers Tableau most of all, plus Power BI, Looker, Hex, SQL and data modelling, the analytics industry, and the craft of doing the job — always tool-agnostic and honest about the trade-offs.

- **Author:** Tim Ngwena (just-tim, https://just-tim.com/about)
- **Published:** 2021-02-09
- **Format:** Video · 14 min watch · transcript available
- **Topics:** Data visualisation, Analytics
- **Tools:** Tableau (index, rank, table calculations)
- **Canonical:** https://just-tim.com/posts/the-index-function-in-tableau
- **Watch:** https://youtu.be/nB8mnxj0wAs

I explain Tableau's INDEX() function, which simply counts rows in your data set but behaves differently depending on partitions and whether it's set to continuous or discrete. I walk through how it works, then show creative uses including combining it with RANK() to count backwards and to keep only the most recent dates.

## Key takeaways

- 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

## Chapters

- 0:22 What the index function does
- 2:45 Measure vs discrete behaviour
- 4:33 Creative bar and circle separation
- 6:07 Partitions and compute using
- 9:24 Counting backwards with rank
- 11:02 Keeping the most recent dates

Watch the full video, read the transcript and use chapter deep-links on the page: https://just-tim.com/posts/the-index-function-in-tableau

---
just-tim — Data and analytics, with a point of view. · https://www.youtube.com/channel/UC7HYxRWmaNlJux-X7rNLZyw · https://twitter.com/TableauTim · https://www.linkedin.com/in/timngwena
