top of page

Blog

Search
Writer's pictureJade @dataunjaded

Need to wrap text labels in Tableau? Just press Enter!

Updated: May 1, 2020

Has anyone else had this problem? Such a beautiful bar chart, but frustratingly cluttered by overlapping labels.

Yes, I’ve tried the logical way… as I’m sure you have too – using the Label settings in the Marks Card to wrap the text. Whyyy won’t you cooperate?


I did several google searches and did find a semi solution here. However, the formula got me thinking…What if I just pressed “enter”?


It’s a pretty simple formula, but I like to take short cuts and let Tableau do the majority of the work. First, right click the label metric you want to wrap and select “Transform -- Custom Split.” Type what separates your data, in this case it’s a space, and select Split off to “All.” Since my field only has up to two words in each category, I'm left with two Split metrics.



Next, create a new calculation. I named it “Wrapped Label (Type of Wine).” Copy and Paste your Split 1 and Split 2 formulas into this new calculation. Then all you have to do is add a line break in-between two quotation marks… aka Just Press Enter!



Text Version:

TRIM( SPLIT( [Metric], " ", 1 ) )

+

'

'

+

TRIM( SPLIT( [Metric], " ", 2 ) )



Finally, drag your new formula on to the Label in the Marks Card...and voila!

This formula can definitely be expanded for longer labels, just add another line break and the next split formula! Any further suggestions or alternatives for this solution? Would love to hear your comments!


5,560 views

Recent Posts

See All
bottom of page