Mar 13, 2015

Conditional Formatting of Background color in Tableau Table

In Tableau if you want to have conditionally formatted background colors, then it’s not there if you use the simple text table. However, you can achieve the same by using bar charts and doing some simple tweaks.

  

Steps to get Conditional formatting of backgrounds in a table. 
  1. Create a bar chart
  2. Create a Calculated field as name “One” and in Formula type 1

  3. Drag this field on to columns shelf
  4. Now edit the axis for it and make it fix axis with values 0 to 1
  5. Also remove any tick marks and make the title blank
  6. Now drop your metric on Label for this Mark.
  7. As per your requirement drop the metric you want to use for conditional formatting on to color in Mark tab. In this case I created a calculated measure ColorForSales with formula =” iif(sum([Order Quantity])>100,1,0)”. Which will show 1 if quantity is > 100
  8. Edit colors for ColorForSales as Red to green diverging and set range as 0 - .5 – 1 and two step color as red and green
  9. Add calculated field ‘One’ again to Columns shelf and make it fixed axis(0,1000000) and remove the axis tick marks.
  10. Select Bar type for this Mark as well and make color of bar as white. As the axis range is fixed at 1 Million, the bar won’t show up. Also hide the labels from the bar
  11. Set the Title for this as you need  (Sales in this case)
  12. Now Make this Mark as dual axis so that the it will appear as the title for the sales Measure
  13. Repeat the process for all the measures you need and your are ready with your Conditionally formatted background Table


If you are showing this in a dashboard then you can avoid adding a additional mark for the headers and can use text labels ( Though you may spend some time aligning them properly)

1 comment: