In Tableau we may have scenarios where we have a list of dimension members, and this list of dimension members may not be exhaustive (complete). However, we may know the other dimension members that may exist (but currently don’t).
An example of this would be on a critical risk dashboard. You have data set up that returns a ‘FALSE’ value if there is a fatal error within your system. It is very unlikely, that this fatal error will exist during the dashboard design phase, and therefore you can only ever colour encode the value ‘TRUE’ (meaning no fatal error).
Here I will outline two methods of ‘encoding in preparation’, for such dimension members.
In these examples I will set the scenario that I have a statement that at present only returns the value FALSE. I want to encode it in case TRUE values appear in the future.
Method 1. Directly in Tableau.
- Create a calculated field. This calculated field will be the one in which your final calculation, or copy of the dimension will exist.
- Within this calculation return, one by one, the values that you predict will exist in the future.
In my case I have used the formula 1<2 to return the value TRUE
- Drag this calculation to the colour shelf
- Encode the colour as appropriate
- If you have more dimension members that you believe will exist in the future, loop through steps 2-5.
- Create your actual calculation.
- Check out your encoded values once they are ‘active’.
Method 2. Hacking the XML.
- Place your dimension or calculated field upon the colour shelf.
- Encode the variables with a colour palette (not automatic).
- Save your workbook as a .twb file, before closing and opening in notepad.
- Identify the location where the current dimension members have been assigned within the XML
- Build out the encoding XML for the missing dimension members and union it underneath the current lines, but before the closing </encoding> tag.
- Save the workbook
- Open your workbook and wait for the dimension member to exist
And that’s how you can ‘colour encode in preparation’.