Switching between discrete and continuous colouring

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.

  1. Create a parameter (or another element, such as a count) that defines whether the chart should be coloured in a continuous or discrete way.2016-08-15_19-10-49
  2. Create a calculated field which will return either the value [Sales] in my case, or NULL when each variable is selected.2016-08-15_19-13-25.png2016-08-15_19-15-43
  3. 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.2016-08-15_19-14-28.png2016-08-15_19-14-57.png
  4. 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.2016-08-15_19-19-33.pngWhilst on my secondary axis, I will drag my [Category] field onto the colours shelf.



  5. 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!




Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s