Ever wanted your users to have the ability to select whether they would like to colour their chart by either a continuous field or through discrete colouring but thought it wasn’t possible?
Well it is!
A use case came up last week and after a brain storm I managed to create this.
Note, this tip relies on a dual axis, so if your chart is already a dual axis then this is not possible (sorry :(), although an alternative would be to switch between your two worksheets dynamically, as outlined here.
- Create a parameter (or another element, such as a count) that defines whether the chart should be coloured in a continuous or discrete way.
- Create a calculated field which will return either the value [Sales] in my case, or NULL when each variable is selected.
- Drag these two pills onto the relevant shelf, in my case I wanted to create a horizontal bar chart, so placed the pills on the column shelf.What you will notice now is that as you switch between the values on your parameter, the charts will take it in turns to appear as your values switch between NULL and the appropriate measure.
- Now that we have two axes, we also have two marks cards, one for each axis that we can treat seperately. We can now format them as so. On the axis that appears when I select ‘Sales’ colouring (i.e. by my measure), i simply drag [Sales] onto the colour shelf.Whilst on my secondary axis, I will drag my [Category] field onto the colours shelf.
- Lastly is some clean up work, hiding the NULL values indicator, creating your dual axis, and then synchronising your axes.Of course you cannot have your axes showing in this case because one of them will always show 0. In that case it is probably wise to label your chart as an alternative or make the values clear in your tooltips.
Indeed it is also possible to switch between chart types and measures using this method!