Two Scenarios to Use first(), last() Function in Tableau

first(),last() function in tableau

Indhumathy Chelliah
Tableau Simplified

--

Photo by DS stories: https://www.pexels.com/photo/close-up-photo-of-a-gold-medal-7267576/

In tableau, you might have come across first() and last() function . Let’s learn about the 2 use cases of using first() and last() in this article.

First let’s learn the difference between first(),last() and index() function.

first() → It will assign 0 to the first row and decreases the number from 0 for the other rows in the partition. (0,-1,-2,-3 etc from the first row in the partition). It returns the number of steps to be taken to reach the first row from the current row.

last() → It will assign 0 to the last row in the partition and increases the number as it goes up. (0,1,2,3 from the last row in the partition). It returns the number of steps to be taken to reach the last row from the current row.

index() → It will return the index of the current row in the partition.

Example: Let’s drag the subcategory and see what first(), last() and index() function do.

Image by Author

Here, if we select binders, we can see that its index is 4 and it is 13 rows up from last row and 3 rows down…

--

--