# The Find, Findnth & Len functions 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-03-10
- **Format:** Video · 14 min watch · transcript available
- **Topics:** Data prep, Data visualisation
- **Tools:** Tableau (calculated fields, find, findnth, len)
- **Canonical:** https://just-tim.com/posts/the-find-findnth--len-functions-in-tableau
- **Watch:** https://www.youtube.com/watch?v=8SbsYcmTREs

I walk through three Tableau string functions: FIND to locate the position of text in a string, FINDNTH to find a specific occurrence, and LEN to return the length of a string. I use Superstore product names and order IDs to demonstrate, then combine the functions with RIGHT and LEFT to extract parts of a string.

## Key takeaways

- FIND returns the position of a piece of text within a string, while FINDNTH lets you target a specific occurrence (e.g. the second hyphen)
- Wrap aggregated string results with MIN, MAX or AVG, and use ATTR to avoid the 'can't mix aggregate and non-aggregate' error
- You can replace the static number in RIGHT or LEFT with a calculation, so the position adapts to each record
- LEN returns the length of any text, which you can subtract from a found position to count characters from the right
- Hold Command (Ctrl on Windows) and scroll to zoom the calculation editor, and double-click a function to wrap it around highlighted text

## Chapters

- 0:00 Introducing FIND and FINDNTH
- 0:20 Setting up with Superstore product names
- 1:25 Building the FIND comma finder
- 3:25 Fixing aggregation and using LEFT
- 7:19 The FINDNTH function
- 9:30 Bonus: the LEN function
- 10:30 Combining functions to extract a string

Watch the full video, read the transcript and use chapter deep-links on the page: https://just-tim.com/posts/the-find-findnth--len-functions-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
