Build an SPC Control Chart Dashboard in Power BI
An end-to-end tutorial for quality and manufacturing engineers: turn raw measurements into an individuals and moving range (I-MR) control chart in DAX, with limits from a baseline, the four Western Electric rules flagged point by point, and Cp/Cpk.
A control chart answers one question: has this process changed, or is it just noise? Every process varies a little from part to part. Statistical process control (SPC) measures how much it varies when nothing is wrong, draws limits around that, and flags the moment the data stops behaving that way, usually well before a single part fails inspection.
Measurements (one value per sample, in time order)
|
| Calculated column: moving range between neighbors
|
Baseline (first 20 samples): center line, sigma, control limits
|
| Measures: z-score per sample, Western Electric rules over a window
|
Dashboard (I chart with signals, moving range chart, Cp / Cpk)Download the data: measurements.csv, or paste the table below into a .csv file yourself.
What You're Building
A one-page control chart dashboard answering the questions a quality review actually asks:
- Is the process stable, or has something changed?
- When did it change, and which rule caught it?
- Is the point-to-point variation itself getting worse?
- How capable is the process against its specification?
+---------------------------------------------------------------+
| Center Line | UCL | LCL | Signals | Cp | Cpk |
+---------------------------------------------------------------+
| I chart: Sample Value, Center Line, UCL, LCL, Signal Point |
+---------------------------------------------------------------+
| Moving range chart | Table: sample, value, |
| (MR, average MR, MR UCL) | z-score, Signal Rules |
+---------------------------------------------------------------+Step 1: The Raw Data
One table: a torque reading from a fastening station, sampled once an hour. The specification is 24.0 ± 0.5 N·m, so anything from 23.5 to 24.5 is a good part.
measurements.csv
SampleNo,Sample,MeasuredAt,Value
1,S01,2026-10-05 06:00,24.02
2,S02,2026-10-05 07:00,23.87
3,S03,2026-10-05 08:00,23.85
4,S04,2026-10-05 09:00,24.01
5,S05,2026-10-05 10:00,23.98
6,S06,2026-10-05 11:00,24.06
7,S07,2026-10-05 12:00,23.75
8,S08,2026-10-05 13:00,23.93
9,S09,2026-10-05 14:00,23.88
10,S10,2026-10-05 15:00,24.12
11,S11,2026-10-05 16:00,24.08
12,S12,2026-10-05 17:00,24.06
13,S13,2026-10-05 18:00,23.98
14,S14,2026-10-05 19:00,24.01
15,S15,2026-10-05 20:00,24.05
16,S16,2026-10-05 21:00,23.86
17,S17,2026-10-05 22:00,24.22
18,S18,2026-10-05 23:00,24.18
19,S19,2026-10-06 00:00,24.27
20,S20,2026-10-06 01:00,23.94
21,S21,2026-10-06 02:00,24.38
22,S22,2026-10-06 03:00,24.23
23,S23,2026-10-06 04:00,24.09
24,S24,2026-10-06 05:00,24.38
25,S25,2026-10-06 06:00,24.13
26,S26,2026-10-06 07:00,24.14
27,S27,2026-10-06 08:00,24.27
28,S28,2026-10-06 09:00,24.07
29,S29,2026-10-06 10:00,24.15
30,S30,2026-10-06 11:00,24.35Scan the column and nothing jumps out. Every reading is inside the spec; the highest is 24.38, still 0.12 under the upper limit. An inspection report for this shift would say "30 of 30 good." But something did change at 2 a.m. on October 6, and by the end of this tutorial the chart will show exactly when.
SampleNo matters more than it looks. Control charts are about order: the moving range compares each reading to the one before it, and the run rules look at the last 3, 5, or 8 readings. Every DAX step below finds "the previous sample" or "the last eight samples" by doing arithmetic on SampleNo, so it has to run 1, 2, 3… with no gaps, in time order.
Step 2: Load the Data
Get Data > Text/CSV, and name the table Measurements. Check the types in Power Query: SampleNo is a Whole Number, Value is a Decimal Number, and MeasuredAt is a Date/Time.
If your own data has no sequence column, make one in Power Query: sort by the timestamp first, then Add Column > Index Column > From 1, and rename it SampleNo. Sorting first is the important part; an index on unsorted rows gives every later step the wrong neighbors.
Step 3: The Moving Range
An individuals chart has one reading per point, so there's no subgroup to measure spread within. Instead, it measures the spread between neighbors: the moving range, the absolute difference between each reading and the one before it.
Table tools > New column:
Moving Range =
VAR ThisSample = Measurements[SampleNo]
VAR PrevValue =
MAXX (
FILTER ( Measurements, Measurements[SampleNo] = ThisSample - 1 ),
Measurements[Value]
)
RETURN
IF ( NOT ISBLANK ( PrevValue ), ABS ( Measurements[Value] - PrevValue ) )For each row, FILTER finds the row whose SampleNo is one less, and MAXX pulls its value out (there's only one row, so MAX is just a way to turn it into a scalar). The first sample has no predecessor, so its moving range is blank, not zero. A zero would tell the average that two readings were identical. See Calculated Columns and Variables if either pattern is new.
The first few rows:
| SampleNo | Value | Moving Range |
|---|---|---|
| 1 | 24.02 | (blank) |
| 2 | 23.87 | 0.15 |
| 3 | 23.85 | 0.02 |
| 4 | 24.01 | 0.16 |
Step 4: Center Line and Control Limits From a Baseline
Control limits describe the process when it's behaving normally, so they have to come from a stretch of data where it was. Here that's the first 20 samples, the baseline. Everything after is monitoring: compared against those limits, but not allowed to move them.
Sample Value =
AVERAGE ( Measurements[Value] )
Center Line =
CALCULATE (
AVERAGE ( Measurements[Value] ),
REMOVEFILTERS ( Measurements ),
Measurements[SampleNo] <= 20
)
Average Moving Range =
CALCULATE (
AVERAGE ( Measurements[Moving Range] ),
REMOVEFILTERS ( Measurements ),
Measurements[SampleNo] <= 20
)
Sigma =
[Average Moving Range] / 1.128
UCL =
[Center Line] + 3 * [Sigma]
LCL =
[Center Line] - 3 * [Sigma]REMOVEFILTERS clears whatever sample the chart is currently on, and the SampleNo <= 20 filter puts back just the baseline. So Center Line returns the same number at every point on the chart, which is what draws it as a flat line. Without REMOVEFILTERS, the "center line" at each point would just be that point's own value. See CALCULATE for how the two filter arguments combine.
1.128 is the SPC constant d2 for ranges of two readings. The average range of two values from a normal distribution is 1.128 standard deviations, so dividing by it converts the average moving range into sigma. (Many textbooks fold it into one number: 3 / 1.128 = 2.66, so the limits are center ± 2.66 × MR̄. Same result.)
With this data:
| Measure | Value |
|---|---|
| Center Line | 24.006 |
| Average Moving Range | 0.128 |
| Sigma | 0.114 |
| UCL | 24.348 |
| LCL | 23.665 |
Notice the control limits are much tighter than the spec (23.5 to 24.5). The spec says what's acceptable; the control limits say what's normal for this process. A reading of 24.38 is a perfectly good part, and also a sign that something has changed.
Step 5: Flag the Western Electric Rules
A point beyond 3 sigma is the obvious signal, but a small shift often never produces one. Instead, it shows up as a pattern: too many points on one side, or a cluster just inside the limit. The four Western Electric rules are the standard set of patterns:
| Rule | Signal | What it usually means |
|---|---|---|
| 1 | One point beyond 3σ | A sudden, large change or a one-off event |
| 2 | 2 of 3 in a row beyond 2σ, same side | A moderate shift |
| 3 | 4 of 5 in a row beyond 1σ, same side | A small, sustained shift |
| 4 | 8 in a row on the same side of center | A shift too small for the other rules |
All four are easiest to test in units of sigma, so start with a z-score: how many sigmas each point sits from the center line.
Z Score =
DIVIDE ( [Sample Value] - [Center Line], [Sigma] )Then one measure checks all four rules for the current point, looking back over the last eight samples:
Signal Rules =
VAR k = MAX ( Measurements[SampleNo] )
VAR Pts =
ADDCOLUMNS (
FILTER (
ALL ( Measurements[SampleNo] ),
Measurements[SampleNo] > k - 8 && Measurements[SampleNo] <= k
),
"@z", CALCULATE ( [Z Score] )
)
VAR z = MAXX ( FILTER ( Pts, Measurements[SampleNo] = k ), [@z] )
VAR Last3 = FILTER ( Pts, Measurements[SampleNo] > k - 3 )
VAR Last5 = FILTER ( Pts, Measurements[SampleNo] > k - 5 )
VAR R1 = ABS ( z ) > 3
VAR R2 =
( z > 2 && COUNTROWS ( FILTER ( Last3, [@z] > 2 ) ) >= 2 )
|| ( z < -2 && COUNTROWS ( FILTER ( Last3, [@z] < -2 ) ) >= 2 )
VAR R3 =
( z > 1 && COUNTROWS ( FILTER ( Last5, [@z] > 1 ) ) >= 4 )
|| ( z < -1 && COUNTROWS ( FILTER ( Last5, [@z] < -1 ) ) >= 4 )
VAR R4 =
k >= 8
&& ( COUNTROWS ( FILTER ( Pts, [@z] > 0 ) ) = 8
|| COUNTROWS ( FILTER ( Pts, [@z] < 0 ) ) = 8 )
VAR Fired =
SUBSTITUTE (
TRIM ( IF ( R1, "1 " ) & IF ( R2, "2 " ) & IF ( R3, "3 " ) & IF ( R4, "4 " ) ),
" ", ", "
)
RETURN
IF (
HASONEVALUE ( Measurements[SampleNo] ) && NOT ISBLANK ( z ) && Fired <> "",
"Rule " & Fired
)
Signal Point =
IF ( NOT ISBLANK ( [Signal Rules] ), [Sample Value] )How it works, piece by piece:
kis the sample the chart is on.ALL ( Measurements[SampleNo] )ignores that filter soFILTERcan see the window of the last eight samples,k - 7throughk.ADDCOLUMNScomputes each window sample's z-score.CALCULATE ( [Z Score] )triggers context transition, so each row's z-score is evaluated for that sample, not fork. See ADDCOLUMNS & SELECTCOLUMNS.Last3andLast5are just the tail of that window, and each rule is a count of rows past a threshold. Rules 2 and 3 also require the current point itself to be out in the zone, so the flag lands on the point that completes the pattern, not on an innocent point after it.Firedbuilds a label likeRule 1, 2, 3;HASONEVALUEkeeps it off the total row.
Signal Point returns the value only where a rule fired. Plotted as a second series with markers and no line, it puts a red dot on exactly the points that matter.
With this data, the baseline has no signals at all (S07 dips to −2.25σ, but one point isn't a pattern). Then:
| Sample | Value | Z Score | Signal Rules |
|---|---|---|---|
| S19 | 24.27 | 2.32 | |
| S20 | 23.94 | −0.58 | |
| S21 | 24.38 | 3.29 | Rule 1, 2, 3 |
| S22 | 24.23 | 1.97 | Rule 3 |
| S23 | 24.09 | 0.74 | |
| S24 | 24.38 | 3.29 | Rule 1 |
| S25 | 24.13 | 1.09 | Rule 3 |
| S26 | 24.14 | 1.18 | Rule 3 |
| S27 | 24.27 | 2.32 | Rule 3 |
| S28 | 24.07 | 0.56 | Rule 4 |
| S29 | 24.15 | 1.26 | Rule 3, 4 |
| S30 | 24.35 | 3.02 | Rule 1, 3, 4 |
S21, the first reading after the baseline, breaks three rules at once: it's past the UCL (rule 1), it's the second of the last three beyond 2σ along with S19 (rule 2), and it's the fourth of the last five beyond 1σ (rule 3). From there, nine of the ten monitoring readings are flagged. By S28, eight in a row have sat above the center line (rule 4), which is about as clear a statement as a control chart makes: the process mean has moved up. The shift turns out to be about 0.21 N·m, roughly two sigma.
Step 6: The Moving Range Chart
The I chart watches the process level. The moving range chart watches its noise: if neighboring readings start jumping around more, the process has lost consistency even if the average hasn't moved.
Moving Range Value =
AVERAGE ( Measurements[Moving Range] )
MR UCL =
3.267 * [Average Moving Range]
MR Signal Point =
IF ( [Moving Range Value] > [MR UCL], [Moving Range Value] )3.267 is the constant D4 for ranges of two readings. The moving range chart's lower limit is zero (D3 is 0 at this size), so there's no MR LCL to draw.
Here MR UCL is 0.420. One moving range crosses it: S21, at 0.44, the jump from 23.94 to 24.38. That's the step itself showing up as one unusually large difference between neighbors. After S21 the moving ranges settle back down, which says the process didn't get noisier. It moved to a new level and stayed there.
Step 7: Process Capability, Cp and Cpk
Capability compares the process's natural spread to the specification. It only makes sense for a stable process, so calculate it from the same baseline the limits came from:
Cp =
DIVIDE ( 24.5 - 23.5, 6 * [Sigma] )
Cpu =
DIVIDE ( 24.5 - [Center Line], 3 * [Sigma] )
Cpl =
DIVIDE ( [Center Line] - 23.5, 3 * [Sigma] )
Cpk =
MIN ( [Cpu], [Cpl] )Cp asks whether the spread would fit if the process were perfectly centered: spec width over six sigma. Cpk asks whether it does fit where the process actually sits: the distance from the mean to the nearer spec limit, in units of three sigma. Cp ignores centering; Cpk doesn't.
On the baseline, Cp is 1.46 and Cpk is 1.45, so the process is centered and comfortably above the common 1.33 minimum.
Now suppose the shift stays. Over S21–S30 the mean is 24.219, and the spread hasn't changed. Cp stays at 1.46, because spread is all it measures. But Cpk falls to 0.82: the upper spec limit is now only 2.5 sigma from the mean, and at that distance you'd expect about 7 parts in 1,000 above 24.5. Not one of the 30 readings is out of spec yet. That's the gap SPC is for.
The spec limits are typed in as numbers here. If they live in a table (a characteristics or part-number table, say), replace 24.5 and 23.5 with MAX of those columns.
Step 8: Lay Out the Report
Page: "Torque SPC"
Row 1 (KPI cards):
[Center Line] [UCL] [LCL] [Cp] [Cpk]
Signals: COUNTROWS ( FILTER ( VALUES ( Measurements[SampleNo] ),
NOT ISBLANK ( [Signal Rules] ) ) )
Row 2 (line chart, the I chart):
X-axis: Measurements[SampleNo] (not Sample: see Common Mistakes)
Y-axis: [Sample Value], [Center Line], [UCL], [LCL], [Signal Point]
Format: UCL and LCL dashed red, Center Line solid
Signal Point: line width 0, markers on, red
Row 3, left (line chart, the moving range chart):
X-axis: Measurements[SampleNo]
Y-axis: [Moving Range Value], [Average Moving Range], [MR UCL], [MR Signal Point]
Row 3, right (table):
Columns: Measurements[Sample], Measurements[MeasuredAt],
[Sample Value], [Z Score], [Signal Rules]Anatomy of a control chart
The tutorial's 30 torque readings in N·m, spec 23.5–24.5, limits from the first 20.
1Individuals chart: center line, ±3σ limits, and the 1σ / 2σ / 3σ zones
Green within 1σ, amber 1–2σ, red 2–3σ. Red dots are signals, labeled with the Western Electric rules they complete.
2Same data, limits from all 30 points
UCL widens from 24.348 to 24.474. The shift no longer crosses a limit, and the only flags left (S08, S09) fall in the stable stretch.
3Capability: ±3σ spread against the spec
Same σ (0.114) both times. Only the mean moved, and Cpk is set by the nearer spec limit.
Limits from the baseline — center 24.006, average moving range 0.128, σ = MR̄ / 1.128 = 0.114. The first reading after the baseline, S21 at 24.38, is past the UCL of 24.348 and completes rules 1, 2, 3 at once; 9 of the 10 monitoring points end up flagged.
Limits from everything — the shifted readings inflate both the center line and σ, so the chart absorbs the very change it should flag, and readings that were fine now look low.
Cpk — 1.45 on the baseline, comfortably capable. If the process stays at its new level, it drops to 0.82, below the usual 1.33 minimum, while every reading is still inside the spec.
Result — the chart flags the change at S21, long before a single part is out of spec. That head start is the whole point of SPC.
A useful extra: a constant line on the I chart at SampleNo 20.5 (in the X-axis Reference line settings), labeled "Baseline ends". It makes it obvious which points set the limits and which are being judged by them. See Charts and Tables for configuring these visuals.
Step 9: Other Chart Types
Individuals and moving range is the right chart when each sample is one measurement. Two other common cases use the same structure with different math:
X̄ and R chart: several measurements per sample (say, five parts measured every hour). Each subgroup is one point; the chart plots its mean, sigma comes from the average subgroup range divided by d2 for that subgroup size (2.326 for five), and the limits for a subgroup mean are three times sigma divided by √n. The rules measure is identical; it just counts subgroups instead of samples.
p chart: a pass/fail count per sample (defectives out of inspected). The center line is the overall defective rate, and sigma is SQRT ( p × (1 − p) / n ), which means the limits change with every sample size: wider for a small batch, tighter for a big one. The z-score approach in Step 5 handles that automatically, because each point is divided by its own sigma.
The Control Chart Builder generates the full DAX for all three, with your table name, subgroup size, baseline, and spec limits filled in, and draws the chart from pasted data so you can check your Power BI version against it point by point. Paste this tutorial's 30 readings in and you'll get the same limits, the same signals, and the same Cpk.
Common Mistakes
Calculating the Limits From All the Data
It seems more thorough to use every reading. Drop the SampleNo <= 20 filter and the limits widen: the center line moves up to 24.077, sigma grows to 0.132, and the UCL rises to 24.474. The shifted readings now set the limits they're being judged by. S21, S24, and S30 all fall back inside, and every signal from the shift disappears.
Worse, the chart now flags the wrong stretch. With the center line pulled up, S01 through S09 all sit below it, so rule 4 (eight in a row) fires on S08 and S09: false alarms during the period when nothing was wrong. Pick the baseline from a period you have reason to believe was stable, and freeze it. Recalculate only after a deliberate, confirmed change to the process.
Using the Standard Deviation for Sigma
Sigma (Wrong) =
CALCULATE ( STDEV.S ( Measurements[Value] ), REMOVEFILTERS ( Measurements ) )STDEV.S measures the spread of everything, including the shift, so it mixes "the process moved" into "the process is noisy." Over all 30 readings it gives 0.162 instead of 0.114, and the UCL climbs to 24.563, above the upper spec limit. A chart like that can never flag anything before parts are already bad. The moving range only compares neighbors, so a shift barely affects it: one big jump at S21, then back to normal. That robustness is exactly why individuals charts use it.
Putting the Sample Label on the Axis
The rules measure looks back over neighboring SampleNo values. With Measurements[Sample] on the X-axis instead, every point also carries a filter like Sample = "S21", which ALL ( Measurements[SampleNo] ) doesn't remove. The window's other samples evaluate as blank, and rules 2, 3, and 4 quietly never fire; only rule 1 still works. Put SampleNo on the axis. If you want the labels shown, put Sample in the tooltips.
Gaps in SampleNo
Both the moving range column and the rules window find neighbors by arithmetic: SampleNo - 1, k - 8. If samples 14 and 15 were deleted as bad readings, sample 16's moving range comes out blank, and every window around the gap is two samples short. Re-index after filtering rows, not before.
Confusing Spec Limits With Control Limits
Drawing 23.5 and 24.5 on the chart as if they were control limits turns it into an inspection chart: it flags a problem only once a part is already bad. Keep both if you like, but in different colors and with different names. The control limits (23.665 to 24.348 here) come from the process; the spec limits come from the drawing.
Reporting Cpk for an Unstable Process
Cpk assumes the process is one stable distribution. Calculated across S01–S30, this process gives a Cpk that's neither the old 1.45 nor the new 0.82, and describes a process that never existed. Fix the signals first, or calculate capability separately for each stable period.
Tutorial Checklist
SampleNoruns 1, 2, 3… in time order with no gaps, and it's on the chart's X-axis.- The moving range is blank for the first sample, not zero.
- The center line and sigma come from a fixed baseline, with
REMOVEFILTERSso they're flat across every point. - Sigma is the average moving range / 1.128, not the standard deviation.
Signal Rulesflags S21 with rules 1, 2, and 3, matching the table in Step 5.- Cp and Cpk come from the baseline, and only get reported while the chart shows no signals.
- Spec limits and control limits are shown differently, if both are shown at all.
Next Steps
- Control Chart Builder: paste measurements or defect counts for an I-MR, X̄-R, or p chart with the rules and capability worked out, plus the DAX for your own table
- Build a Reliability (MTBF/MTTR) Dashboard in Power BI: what happens after a process fails, measured as uptime and repair time
- Build a Pareto Chart Dashboard in Power BI: once the chart flags a change, rank the defect causes to see which few to fix first
- Build an FMEA Dashboard in Power BI: rank failure modes before they happen; a control chart is a common detection control in the D score
- Systems Engineering DAX Patterns Cheat Sheet
- CALCULATE
- ALL(), ALLEXCEPT() & REMOVEFILTERS()
- Calculated Columns
- Variables
FAQ
+How do you make a control chart in Power BI?
Power BI has no built-in control chart visual, but a line chart with four measures makes one: the measured value, a center line, and upper and lower control limits. The limits are measures that use CALCULATE with REMOVEFILTERS so they stay flat across every point, and a separate Signal Point measure plotted as markers puts a red dot on any point that breaks a run rule.
+Why use the moving range instead of the standard deviation for control limits?
The standard deviation of the whole dataset includes any shifts and drifts in the process, so it inflates the limits and hides the very changes a control chart is meant to catch. The average moving range only measures point-to-point variation, so it estimates the process's short-term noise even when the data contains a shift. Dividing it by the constant d2 = 1.128 turns it into sigma.
+What are the Western Electric rules?
Four run rules that flag a process change: one point beyond 3 sigma; 2 of 3 points in a row beyond 2 sigma on the same side; 4 of 5 points in a row beyond 1 sigma on the same side; and 8 points in a row on the same side of the center line. The first catches big jumps; the other three catch smaller shifts that never cross a limit.
+What is the difference between control limits and specification limits?
Specification limits come from the customer or the design: the range a part must fall in to be acceptable. Control limits come from the process's own data: the range it naturally varies within when nothing has changed. A process can be in control and still make bad parts, or out of control while every part is within spec.
+What Cpk value is considered capable?
A Cpk of 1.33 or more is the most common minimum, which puts the nearer specification limit at least 4 sigma from the process mean. Many automotive and aerospace programs require 1.67 for critical characteristics. Cpk only means something once the control chart shows a stable process.