Friday, 15 April 2011

Defending Pie Charts!

Anyone who knows me (in the BI world) knows that I have a certain lack of respect for the humble Pie chart.  I am supportive of Stephen Few's idea that we should, in general, Save the Pies for Desert.


A Pie chart, as it ubiquitously appears in many presentations, used to compare one value against several others, is a very poor choice for the task.  A simple bar chart is by far the better choice for the job.

I have been quite happy, up till now, to reject any use of a pie chart for any purpose.  That was until I came across Robert Kosara's blog entry, In Defence of Pie Charts.  Robert discusses Spence and Lewandowsky's study which shows that pie charts were interpreted more accurately than bar charts in some circumstances.


So, perhaps there is a good use for the Pie chart after all - not in comparison of multiple values, but in simple part-to-whole comparison.


Take, for example, the following Pie chart where we are comparing the performance of Germany versus all other countries.



Now, this chart doesn't give me any numbers but what it does give me is an intuitive feel for how much of the market Germany has.

Now, compare that to an equivalent bar chart.



Here we have a perfectly formed bar chart where we can get a good grasp of the numbers that are involved.  However, if I want to get an idea of what percentage the German total is versus the whole, I have to do a little more work to get the answer - I can't intuit it.

So, for this specific purpose, a Pie chart might be a better choice than the bar.

These charts are easily achieved in QlikView using implicit set analysis (available since version 9).

The chart has no dimension but has 2 expressions.  In my case, the expressions are:

   Sum({<Country=P({$})>} LineSalesAmount)

and

   Sum({<Country=E({$})>} LineSalesAmount)

When I select one or more countries, the first expression will give me the total for the selected countries.  The second expression gives me the reverse, the total for all the other values.

The labels for these can be achieved using Concat.  For the selected countries:

   ='Selected: ' & Concat(DISTINCT Country, ', ')

For the other countries:

   ='Others: ' & Concat({} DISTINCT Country, ', ')




Stephen Redmond is CTO of CapricornVentis a QlikView Elite Partner

1 comment:

  1. Hi Stephen,

    Thank you for this useful tip.
    However, the expressions should be as follow:

    For the selected countries:

    Sum({$} LineSalesAmount)

    and for the other countries:

    Sum({1-$} LineSalesAmount)

    ReplyDelete

Note: only a member of this blog may post a comment.