# The Right () and Left () 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-08
- **Format:** Video · 9 min watch · transcript available
- **Topics:** Data prep, Analytics
- **Tools:** Tableau (calculated fields, left, parameters, right)
- **Canonical:** https://just-tim.com/posts/the-right--and-left--functions-in-tableau
- **Watch:** https://www.youtube.com/watch?v=5Pb7PIFQnuM

I walk through the RIGHT and LEFT string functions in Tableau, using the Superstore Order ID field to isolate a set number of characters from either end of a string. I also explain a common mistake people make with quotation marks and show how to make the character count dynamic using a parameter.

## Key takeaways

- Right-click a field and choose Describe (then Load) to view its metadata and the first 20 or so values
- RIGHT(string, number) returns characters from the end of a string and LEFT(string, number) from the start
- Don't wrap an existing string field in quotation marks - Tableau adds quotes only to mark literal text, and adding them to a field name breaks the calculation
- Hard-coded character counts only work on perfectly consistent data, so this technique has a limited use case on messy data
- Swap the fixed number for a parameter to let users dynamically set how many characters are isolated

## Chapters

- 0:14 Inspecting the Order ID field
- 1:26 Building the RIGHT function
- 2:40 The quotation marks mistake
- 5:30 Duplicating to create the LEFT function
- 6:38 Making it dynamic with a parameter

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