KNOWLEDGE BASE

How to avoid showing duplicate texts in text label data


Published: 16 Nov 2022
Last Modified Date: 17 Nov 2022

Question

How not to repeat the specified string in the text for each data.

<Current Behavior>
User-added image
<Desired Behavior>
User-added image

Environment

  • Tableau Desktop

Answer

1. Connect to Sample Superstore.
2. Create a new calculated field as following.
    Name : Show Category Name
    Calculation : IF FIRST()=0 THEN 'This data has'+'  "'+ATTR([Category])+'"'
                         ELSEIF LAST()=0 THEN '"'+ATTR([Category])+'" .'
                         ELSE '"'+ATTR([Category])+'"'
                         END
3. Drag [Category] to Detail on Marks.
User-added image
4. Drag [Show Category Name] to Text on Marks.
User-added image
5. Right click on [Show Category Name] on Marks -> Edit Table Calculation -> Set as following.
User-added image
 
Did this article resolve the issue?