KNOWLEDGE BASE

How To Color The Text And Kpi Shape In The Crosstab Simultaneously To Show The Change Of Values


Published: 17 Jul 2020
Last Modified Date: 22 Jul 2020

Question

How to put the text and KPI/Currency shape on color in a crosstab simultaneously to show the change of values as below?
 

Cost TypeApr-20May-20Jun-20
A£-2000£3000£-1000
B£1000£-2000£-3000
C£-3000£-1000£-2000
Total£-4000£0£-6000

We could put multiple fields on color in some chart types, for example, treemaps and bullet graphs. However, in a crosstab, this could not be achieved if we have already assigned shapes to show the value changes. Dropping the value measure on color will only change the color of the shapes instead of the texts. How can we color the text at the same time?
User-added image

Environment

  • Tableau Desktop

Answer

Use Customized Shape and Dual Axis to show colored shapes and texts in one view.
User-added image
1. Put Date to Columns, Cost Type to Rows, and Value to Label Mark and then create a crosstab.
2. Create three calculations (the value in a & b could be edited to make shapes and texts align better in the view if necessary):
a. Shape: 0.1
b. Text:0.4
c. Profitable: IF SUM([Value])>=0 THEN 'True' Else 'False' END
3. Put Shape and Text we just created to Columns and change both the measure types to Average.
4. Right-click AVG(Text) and click Dual Axis.
5. Under AVG(Shape) Mark, remove the existing fields, change the mark type to Shape, and drag Profitable to Shape. Change the shape to KPI Platte. (You can add your preferred shape here)
6. Under AVG(Text) Mark, remove the existing Measure Names and drop Value to Color, change the mark type to Text. When editing color, set stepped color to 2 steps and select red to all negative values and black to positive values. Select "Include Total" if needed.
7. In the view, right-click the AVG.Text axis, select Synchronize Axis.
8. Narrow the columns and hide axis headers.
Did this article resolve the issue?