How to Wrap Text in Tableau
By default, text in Tableau wraps based on available space and word breaks. However, if you want to control where the text breaks manually, here's how to do it.
We'll assume that the first word in the Product Name field of the Superstore dataset is the Brand. Let’s walk through how to separate the brand from the rest of the product name and add a line break between them.
First, use the SPLIT
function to extract the brand name, which is the text before the first space.
SPLIT([Product Name],' ',1)
Next, use the FINDNTH
and MID
functions to get the rest of the product name, excluding the brand.
TRIM(MID([Product Name],FINDNTH([Product Name],' ',1)))
Finally, add a line break between the two by using the ASCII code CHAR(10)
. The final calculation will look like this:
You could also wrap the line break in quotation marks like this, but for cleaner formulas, I recommend using the ASCII code method.
Additionally, when trying to force a line break in measure names by adding multiple spaces, it’s better to use a cleaner approach. Refer to the guide below to create a header using a Placeholder for a more polished result.