In quality control, you often want to look at the distribution of a measurement, to understand how the output of a process or a machine relates to expectations; to targets and specifications. In such a case, a histogram (or frequency plot) is one possibility.
It could be that you want to examine some physical property of the output of a machine, and want to see how close to target the produced units are. Then you could plot the measurements in a chart like the following:
The above graph clearly shows you the distribution of the output of the machine: Most measurements are around target and the peak of the distribution is in fact slightly above target. But the histogram also raises questions: Is the variation small enough? And why is there such a long tail towards lower values? Could it be that we have a problem with a machine?
Finding such questions and their answers is central in all quality work, and the histogram is a good tool in helping you find them.
A histogram is special type of bar chart, and is easy to create in QlikView. A peculiarity is that it uses only one field, not several: As dimension, it uses the measurement in grouped form: Each measurement is assigned to an interval or bin, and this way the dimension gets discrete values.
As expression it uses the count of the measurement, and so the graph shows the distribution of one single field.
One small challenge is to determine how many bins the histogram should have: Having too many bins will exaggerate the variation, whereas too few will obscure it. A simple rule of thumb is to have 10-15 bins.
This is how you create a histogram in QlikView:
Create an Input Box. In its properties, create a new variable called BinWidth. Click OK.
Set BinWidth to 1 in the Input Box.
Create a Bar Chart with a calculated dimension, using =Round(Value, BinWidth)
Set the label for the calculated dimension to “Measurement”. Click Next.
Use Count(Value) as expression. Click Next.
Sort the calculated dimension numerically. Click Next three times.
On the “Axes” page, enable “Continuous” on the Dimension Axis. Click Next.
On the “Colors” page, disable the “Multicolored” under Data appearance. Click Finish.
You should now have a histogram.
If you have too few bars, you need to make the bin width smaller. If you have too many, you should make it bigger.
In order to make the histogram more elaborate you can also do the following:
Add error bars to the bins. The error (uncertainty) of a bar is in this case the square root of the bar content, i.e. Sqrt(Count(Value))
Add a second expression containing a Gaussian curve (bell curve):
Convert the chart to a Combo chart
Use the following as expression for the bell curve: Only(Normdist(Round(Value,BinWidth),Avg(totalValue),Stdev(totalValue), 0))*BinWidth*Count(totalValue)
Use bars for the measurement and line for the curve.
With these changes, you can quickly assess whether the measurements are normally distributed or whether there are some anomalies.
Also can I somehow adjust X-axis tick position, so that it was drawn not in the center of a bar, but near its left/right border (like it's usually done on a histogram)?
I've managed to build the histogram following your recipe (thanks for that !). I've been trying to build on this and incorporate variable in the formulas. Essentially, I'm replacing the 'Val' field by a variable which points to one field or another based on a selection.
With all formulas, inserting a variable works but for the Upper / Lower whiskers this doesn't work. Below overview of the difference pieces:
I assume that the variable "vPrice" points at a field and doesn't contain a numeric value. In other words - "vPrice" should expand to a text string that corresponds to a field name.
If so, your definition of the variable is wrong. You use