QlikView for Developers Cookbook
上QQ阅读APP看书,第一时间看更新

Creating a box plot chart for a simple data set

Box plot charts, or box and whisker charts, are often used for displaying statistical mean and quartile information.

This can be useful for seeing how a value ranges across categories by visualizing the median, the twenty-fifth and seventy-fifth percentile, and the outlying values.

With a simple data set, it is easier to create the chart manually than using the wizard that QlikView provides—although there is a slightly strange sequence of actions to go through a "funny"—that you need to know about.

Getting ready

Load the following script:

LOAD * INLINE [
    Country, Value
    USA, 12
    USA, 14.5
    USA, 6.6
    USA, 4.5
    USA, 7.8
    USA, 9.4
    UK, 11.3
    UK, 10.1
    UK, 3.2
    UK, 5.6
    UK, 3.9
    UK, 6.9
];

How to do it…

There is a "funny" in here because you have to tell the chart properties that you are using a box plot, then click on OK and then go back in and edit the properties. Here's how you do it:

  1. Create a new combo chart. Select Country as the dimension.
  2. When the expression editor pops up, just enter 0 as the expression. It doesn't really matter what you enter, you just need to enter something.
  3. Deselect Bar and select Box Plot. At this stage, just click on Finish. Your chart will come up with No Data to Display—this is not a problem.
  4. When you go back into editing the expression properties, you will find five new subexpressions. Enter the following expressions for each of them:
  5. Add two new expressions:
    Max(Value)
    Min(Value)
  6. For the two new expressions, deselect the Line option (or Bar if it is selected) and select the Symbol option. Select Circles from the Symbol drop-down menu:
  7. On the Presentation tab, turn off Show Legend. Set the Symbol Size option to 3 pt:
  8. Check that the box plot looks like the following screenshot:

How it works…

The five separate values define the different portions of the box plot:

There's more…

This recipe is for when you have a simple set of data and you are looking for the statistics across all of the data.

In QlikView, we can have much more control of the values in the box plot, especially where we want to look at averages and percentiles of aggregated data.

As well as box plots, within the combo chart settings there is also a Stock option, which allows us to specify the minimum, the maximum as well as an open and close value.

See also

  • The Using the wizard to create a box plot chart recipe