Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Share your agentic AI experience, learn from others, and earn a new badge: Put Agentic AI to Work
hic
Former Employee
Former Employee

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:

Histogram.png

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:

  1. Create an Input Box. In its properties, create a new variable called BinWidth. Click OK.
  2. Set BinWidth to 1 in the Input Box.
  3. Create a Bar Chart with a calculated dimension, using =Round(Value, BinWidth)
  4. Set the label for the calculated dimension to “Measurement”. Click Next.
  5. Use Count(Value) as expression. Click Next.
  6. Sort the calculated dimension numerically. Click Next three times.
  7. On the “Axes” page, enable “Continuous” on the Dimension Axis. Click Next.
  8. On the “Colors” page, disable the “Multicolored” under Data appearance. Click Finish.

Input box.png

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(total Value),Stdev(total Value), 0))*BinWidth*Count(total Value)
    • Use bars for the measurement and line for the curve.

Histogram2.png

With these changes, you can quickly assess whether the measurements are normally distributed or whether there are some anomalies.

Good luck!

HIC

Further reading related to data classification:

Recipe for a Box Plot

Recipe for a Pareto Analysis

Buckets

38 Comments
hic
Former Employee
Former Employee

The second expression defines the red line. In the end of the blog post there are a coupe sentence that describe what you should do to create this.

0 Likes
7,511 Views
Anil_Babu_Samineni
MVP
MVP

I created one chart

Dimension

----------------

=Round([2014 Score] ,BinWidth)

Expression

-----------------

BinWidth*Count(total [2014 Score])* Only(Normdist(Round([2014 Score],

BinWidth),Avg(total [2014 Score]), Stdev(total [2014 Score]),0))

Do i required to change any options?

Yesterday, I posted on community about this with qvw. Can you please have a look that

Re: Bell Curve Problem

0 Likes
7,511 Views
Not applicable

hic‌,

is there a way to also include missing data-intervals into the histogram?

What I mean:

A sample data (generated in R): d <- c(rnorm(20, mean = 0), rnorm(20, mean = 50))


hist(d) shows it correctly:

2016-07-20_1512.png

While in QV, if using your method without any enhancement, the gap is not shown:

2016-07-20_1512_001.png

It's obvious to me why QV shows the chart like that, but the question is how to present data with gaps correctly.

0 Likes
7,511 Views
hic
Former Employee
Former Employee

Change to "Continuous Axis". (Under Properties - Axes)

HIC

0 Likes
7,511 Views
Not applicable

Thanks!

0 Likes
7,283 Views
Not applicable

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)?

0 Likes
7,283 Views
Not applicable

Hi Henric,

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:

Formula without variable:

Min(If(CTCT_AMOUNT_PC>= Aggr(2.5*Fractile(total <[Region Geography]> CTCT_AMOUNT_PC,0.25) -1.5*Fractile(total <[Region Geography]> CTCT_AMOUNT_PC,0.75), [Region Geography], CTCT_AMOUNT_PC), CTCT_AMOUNT_PC))

Formula with variable:

Min(If($(vPrice)>= Aggr(2.5*Fractile(total <[Region Geography]> $(vPrice),0.25) -1.5*Fractile(total <[Region Geography]> $(vPrice),0.75), [Region Geography], $(vPrice)), $(vPrice)))

Variable:

if(%Pricing_UOM= 'Price/PC',CTCT_AMOUNT_PC,CTCT_AMOUNT_CS) where is a selection field.

Would you have any insights into why this doesn't work with the variable and how to fix it ?

Thanks,

Simon

0 Likes
7,283 Views
hic
Former Employee
Former Employee

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

     If(%Pricing_UOM= 'Price/PC',CTCT_AMOUNT_PC,CTCT_AMOUNT_CS)

which will pick the value of Only(CTCT_AMOUNT_PC) or Only(CTCT_AMOUNT_CS), but instead you want the name of the field. I.e.

     If(%Pricing_UOM= 'Price/PC','CTCT_AMOUNT_PC','CTCT_AMOUNT_CS')

Note the additional single quotes.

HIC

0 Likes
7,283 Views
Not applicable

Thanks ! That was indeed the issue. I should have thought about this...

0 Likes
7,283 Views
hic
Former Employee
Former Employee

"Experience" is the name everyone gives to their mistakes.

     - Oscar Wilde

7,283 Views