KNOWLEDGE BASE

How To Add Trend Line with String Dimension


Published: 06 Feb 2020
Last Modified Date: 07 Feb 2020

Question

How To Add Trend Line with String Dimension

Before
User-added image

After
User-added image

Environment

  • Tableau Desktop 

Answer

1. Create calculation field [Order] using RANK to define how you want to sort [Category]
ex: sort by Data source order
RANK(ATTR([Category]),'asc')

2. Drag [Category] from [Columns] to [Detail]
3. Drag [Order] to [Columns]

4. Right click on [Order] -> [Compute Using] -> [Category]

5. Create calculation field [Label]
AVG(-1)

6. Drag [Label] to [Rows]

7. Remove all fields in [Label] Marks card

8. Drag [Category] to [Label] in [Label] Marks card

9. Change mark type to [Text] in [Label] Marks card

10. Right click on [Label] in [Rows] -> [Dual Axis]

11. Right click on [Label] axis -> [Synchronize Axis]

12. Right click on [Label] axis -> [Show header] to hide header

13. Remove [Measure Names] from Marks card

14. Adjust [Size] of [Sales]

15. Right click on [Order] axis -> [Show header] to hide header

16. Drag [Trend Line] from [Analytics] to SUM([Sales])
 
Did this article resolve the issue?