Control charts in a spreadsheet: pitfalls and how to avoid them

Updated

You can build a correct control chart in a spreadsheet, but most homemade charts contain at least one of a handful of mistakes that make them miss real signals. The most damaging is computing the limits from the standard deviation of all the data, which makes the limits too wide whenever the process has shifted. Others are using specification limits as control limits, formulas whose limits move every time a row is added, wrong constants, sorted data and no run tests. This article shows each pitfall and the correct formula, with a worked example where the wrong limits hide a shift that the right ones catch.

Pitfall 1: limits from the overall standard deviation

The most common spreadsheet chart sets the limits at the average plus and minus three times STDEV of the whole column. It looks reasonable, and it is wrong for a control chart.

Control limits must be based on short-term variation: the moving ranges between consecutive values for an individuals chart, or the ranges or standard deviations within subgroups for an Xbar chart. The standard deviation of the whole column includes every shift, drift and special cause in the data. The more the process moved, the wider the limits become, until the chart cannot see the movement that inflated them.

Example: coating weight per coil

A coil coating line takes one sample per coil and records the coating weight in g/m². Starting with coil 13, a new lot of coating solution was used. These are 24 coils, in time order:

CoilsCoating weight (g/m²)
1 to 1248.9, 49.7, 49.7, 49.8, 51.1, 50.1, 50.4, 50.0, 49.1, 50.2, 50.7, 50.1
13 to 2453.5, 52.8, 55.6, 53.2, 53.2, 52.7, 54.3, 54.1, 53.2, 53.8, 54.2, 53.6

The mean of all 24 values is 51.83 g/m². Now compare the two ways of setting the limits.

Wrong: overall standard deviation. STDEV of the column is 2.014 g/m². The limits are 51.83 ± 3 × 2.014, or 45.79 to 57.88 g/m². Every coil is comfortably inside.

Coating weight with limits from the overall standard deviation (wrong)5055Coating weight (g/m²)CL=51.83UCL=57.88LCL=45.791471013161922Coil
Coating weight with limits from the overall standard deviation (wrong)

Right: average moving range. The 23 moving ranges (the absolute differences between consecutive coils) add up to 21.1, so MR̄ = 0.917 g/m² and σ̂ = MR̄ / 1.128 = 0.813 g/m². The limits are 51.83 ± 3 × 0.813, or 49.39 to 54.27 g/m².

Coating weight with limits from the average moving range (right)50525456Coating weight (g/m²)CL=51.83UCL=54.27LCL=49.391471013161922Coil
Coating weight with limits from the average moving range (right)

Now coils 1 and 9 are below the lower limit, and coils 15 and 19 are above the upper limit. The chart says clearly that the process ran at two different levels. Within each half the process is quite consistent: the first 12 coils average 49.98 g/m² with a standard deviation of 0.61, the last 12 average 53.68 with 0.80. The overall standard deviation of 2.01 is large mainly because of the jump between the halves, which is exactly what the chart should reveal.

The run test for nine points in a row on one side of the center line (Test 2 of the tests for special causes) would also catch this shift, at coil 9. But most spreadsheet charts check only for points beyond the limits, so the wrong limits leave nothing to see.

The correct formulas

For an I-MR chart with the data in B2:B25 (row 1 holds the header):

CellFormulaWhat it is
C3, filled down to C25=ABS(B3-B2)Moving range
F1=AVERAGE($B$2:$B$25)Center line
F2=AVERAGE($C$3:$C$25)MR̄
F3=F1+3*F2/1.128Upper control limit
F4=F1-3*F2/1.128Lower control limit
F5=3.267*F2Upper limit of the moving range chart

For an Xbar-R chart, compute each subgroup's mean and range in its row, then use x̄̄ ± A₂R̄ for the Xbar chart and D₃R̄ to D₄R̄ for the range chart, with the constants for your subgroup size (A₂ = 0.577, D₃ = 0, D₄ = 2.114 for subgroups of 5).

Pitfall 2: specification limits on the chart

Drawing the tolerance as the "limits" turns a control chart into an inspection record. It can only tell you that a part failed, not that the process changed while parts were still good. Specification limits belong in a capability analysis; control limits come from the data. If you want the tolerance visible, show it on a histogram next to the chart, never on a chart of subgroup averages.

Pitfall 3: limits that move with every new row

A formula such as =AVERAGE(B:B) or a range that grows automatically recomputes the limits each time a value is added. A gradual drift then pulls the center line and widens the limits as it happens, and never signals. Compute the limits from a fixed baseline range (with absolute references such as $B$2:$B$25), and plot new data against those frozen limits. Recompute only after a deliberate change to the process, as described in the implementation guide.

Pitfall 4: wrong constants and formula slips

Small errors in the formula change the limits a lot:

  • Forgetting to divide MR̄ by 1.128, which makes the limits 13% too wide.
  • Using 2.66 (that is, 3 / 1.128) and then also dividing by 1.128.
  • Using the constants for the wrong subgroup size. A₂ is 0.729 for subgroups of 4 and 0.577 for subgroups of 5.
  • Using one constant for subgroups of different sizes. If some subgroups are incomplete, each needs its own limits, or use an Xbar-S chart.
  • Using the sample standard deviation within subgroups without the c₄ correction when the method calls for it.

A simple safeguard: before you trust a template, run a published example through it and check that you get the same limits. The coating weight data above are a good test for an I-MR template.

Pitfall 5: data that lost their time order

A control chart only works on data in the order they were produced. Sorting the column (to find the largest value, for example) destroys the moving ranges and the runs. Filtering out rows, pasting data from two machines into one column, or collecting results in the order they were measured rather than produced has the same effect. Keep a time stamp or sequence number in every row, and keep separate streams (machines, cavities, shifts if they differ) in separate columns or charts.

Pitfall 6: blanks, text and zeros

Spreadsheets treat missing data in different ways depending on the function. A blank cell may be ignored by AVERAGE but counted as zero in a subtraction, which creates a huge moving range. A value typed with a comma as the decimal separator may be stored as text and silently left out. Check the count of numeric values against the number of rows, and handle missing values explicitly: leave the moving range blank on both sides of a missing value.

Pitfall 7: no run tests

Conditional formatting that colors points beyond the limits implements only Test 1. Shifts of one or two standard deviations, like the one in the example, are much more quickly caught by Tests 2, 5 and 6. Writing those rules in spreadsheet formulas is possible but error-prone; if you do it, test it on data where you know the answer, such as the small examples in the tests for special causes.

When a spreadsheet is enough

A spreadsheet works for a few charts that one person maintains, with a template that has been checked against a known example and limits that are frozen. It becomes fragile when many people edit it, when charts multiply, or when you need run tests, varying subgroup sizes or attribute charts. A good statistics tool should compute the limits the standard way, keep the data in time order, apply the tests you choose and show which test fired at which point.

Frequently asked questions

Should I use STDEV.S or STDEV.P for control limits?

Neither, for the limits themselves. Control limits for an individuals chart use the average moving range divided by 1.128; Xbar charts use the average range or average subgroup standard deviation. STDEV.S, the sample standard deviation, is right for the overall standard deviation in a capability analysis (Pp and Ppk).

Can I use the overall standard deviation if my process is stable?

If the process is truly stable, the two estimates are close, so the limits would be similar. But you do not know the process is stable until the chart, built with short-term variation, tells you. Using the overall standard deviation assumes the answer.

Why does my spreadsheet chart never show any points out of control?

The most likely reasons are limits based on the overall standard deviation, limits that recompute with every new row, or subgroups that mix several streams and inflate the ranges. Check the three in that order.

Is a 2.66 constant correct for individuals charts?

Yes. The limits are x̄ ± 3 × MR̄ / 1.128, and 3 / 1.128 = 2.66, so x̄ ± 2.66 × MR̄ gives the same result. Just do not divide by 1.128 a second time.

Try it with your own data

StatLab SPC is free, open-source statistics for engineers. It runs in your browser, works offline, and never uploads your data.

Open StatLab