Announcements
Former Employee

Recipe for a Box Plot

When you want to look at the distribution of a measurement, a histogram is one possibility. However, if you want to show the distribution split over several dimensional values, a Box Plot may be a better choice.

You may, for instance, want to evaluate the quality of units produced in different machines, or delivered by different suppliers. Then, a Box Plot is an excellent choice to display the characteristic that you want to examine:

The graph clearly shows you the performance of the different machines compared to target: Machine A has the precision, but not the accuracy. Machine F has the accuracy, but not the precision.

The Box Plot provides an intuitive graphical representation of several properties of the data set. The box itself represents the main group of measurements, with a center line representing the middle of the data. Usually the median and the upper and lower quartile levels are used to define the box, but it is also possible to use the average plus/minus one standard deviation.

The whiskers are used to show the spread of the data, e.g. the largest and smallest measurements can be used. Usually, however, the definition is slightly more intricate. Below I will use the definition used in six sigma implementations.

There, the whiskers are often used to depict the largest and smallest values within an acceptable range, whereas values outside this range are outliers.

The concept of the Inter Quartile Range (IQR) – the difference between the upper and lower quartile level – is used to calculate the acceptance range. Hence:

• Inter Quartile Range (IQR) = Upper Quartile Line (UQL) – Lower Quartile Line (LQL)
• Upper Acceptance Limit (UAL) = UQL + 1.5 * IQR
• Lower Acceptance Limit (LAL) = LQL - 1.5 * IQR

The picture below summarizes the box plot.

And here is how you implement this in QlikView…

1. Go to the Tools menu and choose “Box Plot Wizard”.
2. On the “Step 1 - Define data” page, you choose your dimension. In my example, this was Machine, but it could be Supplier or Batch or something similar.
3. Use the same dimension once more in the “Aggregator” control.
4. Use the average of your measurement in the “Expression” control – Avg(Measurement).
5. Click “Next”.
6. On the “Step 2 - Presentation” page, you should choose “Median mode”.
7. Check “Include Whiskers” and “Use Outliers”.
8. Click “Finish”.

QlikView has now created a Box Plot with general expressions that almost always display a meaningful result, and allows for an intermediate aggregator. However, the expressions are not what we want for a six sigma box plot, so we need to change them to the following: (Below, the dimension is called Dim, and the measurement is called Val.)

• Box Plot Middle: Median(Val)
• Box Plot Bottom: Fractile(Val,0.25)
• Box Plot Top: Fractile(Val,0.75)

The whiskers and the outliers all need a nested aggregation – each value needs to be compared to the acceptance levels for the group – so they all contain an Aggr() function that calculates the relevant acceptance limit:

• Box Plot Lower Whisker:
Min(If(Val>= Aggr(2.5*Fractile(total <Dim> Val,0.25) -1.5*Fractile(total <Dim> Val,0.75), Dim, Val), Val))
• Box Plot Upper Whisker:
Max(If(Val<= Aggr(2.5*Fractile(total <Dim> Val,0.75) -1.5*Fractile(total <Dim> Val,0.25), Dim, Val), Val))
• Lower Outlier:
Min(If(Val< Aggr(2.5*Fractile(total <Dim> Val,0.25) -1.5*Fractile(total <Dim> Val,0.75), Dim, Val), Val))
• Upper Outlier:
Max(If(Val> Aggr(2.5*Fractile(total <Dim> Val,0.75) -1.5*Fractile(total <Dim> Val,0.25), Dim, Val), Val))

And with this, I leave you to create your own box plots.

HIC

Further reading related to data classification:

Recipe for a Histogram

Buckets

Recipe for a Pareto Analysis

Former Employee

You need to check your expressions for the Bottom, Top and Whiskers. They seem to be undefined or have wrong values.

HIC

4,617 Views
Creator II

Thanks Henric,

this was indeed the case. I misunderstood that I would already see a plausible plot when I follow just Step 1-8 without adapting the expressions of Boxes and wiskers. I thought that these later steps were to make the box plot in accordance to Six-Sigma guidelines.

4,617 Views
Contributor II

Many thanks for this post Henric.

Do you know if it's possible to show all the points between the Upper Acceptance Limit and the Upper Outlier, please ? This is possible, for example, in the R boxplot :

Best regards,

Stéphane

4,607 Views
Former Employee

The box plot in Qlik Sense does this automatically. Try it!

The box plot in QlikView is not as flexible, but you can make it to show a second, or third outlier:

Do the following:

1. Right-click the Upper Outlier in the list of measures. Choose Copy.
2. Right-click in the list of measures. Choose paste.
3. Insert a second parameter in the Max function
Max( ... , 2 )
Then you will get the second highest value - the second outlier.

HIC

4,607 Views
Contributor II

Oh ! Indeed, this is very nice ! Thanks a lot for this tip.

Well, I hope we will soon be able to work on Qlik Sense.

Thanks again Henric.

Stéphane

4,607 Views
Luminary Alumni

Hi everyone,

Qlik Sense is great and creates the chart automatically with the possibility to

I'm trying to find how to add the last value of the series in the box plox in Qlik Sense. Didn´t found a way to show this in the same chart as a symbol, just like in the combo chart.

Any clues ?

3,447 Views
Creator

Hello Henric.

It will be glad if you can assist.

I used the box plot wizard and i have the below box plot.

The exressions i take are the below:

Fractile(Aggr(Fractile(M.V,0.05),[P.O],[M.V]), 0.5)

Fractile(Aggr(Fractile(M.V,0.05),[P.O],[M.V]), 0.25)

Fractile(Aggr(Fractile(M.V,0.05),[P.O],[M.V]), 0.75)

Fractile(Aggr(Fractile(M.V,0.05),[P.O],[M.V]), 0.75)

max(Aggr(Fractile(M.V,0.05),[P.O],[M.V]))

I added an If function like that  but i have not results:

If(Des='φ',Fractile(Aggr(Fractile(M.V,0.05),[P.O],[M.V]), 0.5))

If(Des='φ',Fractile(Aggr(Fractile(M.V,0.05),[P.O],[M.V]), 0.25))

If(Des='φ',Fractile(Aggr(Fractile(M.V,0.05),[P.O],[M.V]), 0.75))

If(Des='φ',min(Aggr(Fractile(M.V,0.05),[P.O],[M.V])))

If(Des='φ',max(Aggr(Fractile(M.V,0.05),[P.O],[M.V])))

With this function i want to create separate box plots for each Des (you must see data).

In the link ( https://community.qlik.com/t5/QlikView-App-Dev/Boxplot-expressions-and-etc/m-p/1986658#M1221207 )you can find the originall post with the qvw and raw data.

Best regards.

423 Views
Creator

Hello Henric.

In case i dont have UAL & LAL.

what expressions i need just to show the whiskers and outliers?

Best regards

347 Views
Subscribe by Topic