A p chart is a statistical process control tool for tracking the proportion of defective items in samples of varying size. Excel has no built-in p chart type, but you can build one reliably with a helper table and a line chart: calculate the overall proportion (p-bar), the per-sample proportion, and the upper and lower control limits (UCL/LCL) for each sample, then plot all four series on one chart. The steps below work in Excel for Microsoft 365 and Excel 2019/2021 on Windows and Mac; menu labels may differ slightly by version, and the Analysis ToolPak is not required.

What You'll Need

  • Excel 2019, 2021, or Microsoft 365 (Windows or Mac). Excel for the web can create the chart but has fewer formatting options.
  • A data table with one row per sample: a sample label or date, the number inspected (n), and the number defective (np).
  • At least 20–25 samples for the control limits to be meaningful; fewer samples give unreliable limits.
  • Basic familiarity with writing formulas and inserting a line chart.

Step-by-Step

  1. Lay out your data. In columns A, B, and C, enter headers: Sample, n (inspected), and Defective. Fill one row per sample. Keep n in the same units as Defective (both counts, not percentages).
  2. Calculate p-bar. In an empty cell, say F2, enter =SUM(C2:C26)/SUM(B2:B26), adjusting the ranges to your data. This is the overall proportion defective across all samples. Label it p-bar in E2.
  3. Calculate the per-sample proportion p. In D2 enter =C2/B2 and fill down to the last sample row. Format column D as a percentage or a decimal with 4 places.
  4. Calculate the control limits. The standard formulas are:
    UCLi = p-bar + 3 × √(p-bar × (1 − p-bar) / ni)
    LCLi = p-bar − 3 × √(p-bar × (1 − p-bar) / ni)
    In E2 (UCL) enter =$F$2+3*SQRT($F$2*(1-$F$2)/B2) and in F2... use separate columns: put UCL in E2 and LCL in F2 with =$F$2-3*SQRT($F$2*(1-$F$2)/B2) — but F2 already holds p-bar, so place p-bar in H2 and use H2 in the formulas instead. A clean layout is: E = UCL, F = LCL, H = p-bar. Fill E and F down. If LCL computes below 0, set it to 0 with =MAX(0, ...), since a negative proportion is impossible.
  5. Add a p-bar line column. In G2 enter =$H$2 and fill down, so the centre line plots across every sample.
  6. Select the chart data. Highlight the sample labels (A2:A26) and the p, UCL, LCL, and p-bar columns (D, E, F, G) together. If the columns are not adjacent, hold Ctrl (Windows) or Command (Mac) while selecting.
  7. Insert a line chart. Go to Insert > Charts > Line and choose Line with Markers. A chart appears with four series.
  8. Fix the series assignment. If Excel plotted the sample numbers as a series, right-click the chart, choose Select Data, and set the Horizontal (Category) axis labels to your sample column. Remove any series that should not be there.
  9. Format the control lines. Right-click the UCL series, choose Format Data Series, and set a solid line with no markers. Repeat for LCL and p-bar. Keep markers only on the p series so the actual data stands out.
  10. Set the axis. Right-click the vertical axis, choose Format Axis, and set the minimum to 0 and the maximum slightly above your highest UCL. Set the number format to percentage if you prefer.
  11. Add a chart title and axis titles. Use Chart Design > Add Chart Element to add a title such as p Chart — Proportion Defective and label the vertical axis Proportion.
  12. Interpret. Points inside the limits and randomly scattered indicate a stable process. A point outside UCL or LCL, or a run of seven or more points on one side of p-bar, signals a special cause worth investigating.

Common Mistakes

  • Using percentages instead of counts. p-bar must be computed from total defective ÷ total inspected, not by averaging the per-sample percentages. Averaging percentages weights small and large samples equally and gives a wrong centre line.
  • Using a fixed n in the limits. The whole point of a p chart is that n can vary; the limits must be recalculated per sample using that sample's n.
  • Leaving LCL negative. A negative lower limit is meaningless; cap it at 0.
  • Plotting too few samples. Limits from five or ten samples are not trustworthy.
  • Mixing chart types. Plotting p as columns with limits as lines can look fine but makes it harder to read runs; a single line chart with distinct line styles is standard.
  • Forgetting to lock p-bar with absolute references. Without the $ signs, filling the formula down shifts the p-bar cell and produces nonsense limits.

Tips

  • Use a consistent sample size where possible; constant n makes the limits straight horizontal lines and the chart much easier to read.
  • Format UCL and LCL as dashed red lines and p-bar as a solid grey line — a widely used convention that readers recognise instantly.
  • Add a helper column that flags points outside the limits with a formula such as =IF(OR(D2>E2,D2<F2),"Out",""), then use it to label out-of-control points.
  • Keep the raw n and defective counts visible next to the chart so anyone can audit the calculation.
  • If you need this repeatedly, save the workbook as a template with the formulas already in place.

Troubleshooting

  • The chart shows sample numbers on the X axis. Excel treated the labels as values. Use Select Data and set the horizontal axis labels explicitly to the sample column.
  • The limits look flat when n varies. Check that the formula references the n cell for that row (B2, B3, …) and not a single fixed cell.
  • p-bar looks wrong. Verify that the SUM ranges cover exactly the same rows and that no blank or text cells sit inside them.
  • #DIV/0! errors. A sample has n = 0 or a blank n cell. Remove or fix that row.
  • Lines do not appear. The series may be hidden or assigned to the secondary axis. Right-click the series and check the axis setting.
  • Chart looks cramped. Reduce marker size, or switch the p series to markers only and keep the limits as plain lines.

Frequently Asked Questions

Does Excel have a built-in p chart?

No. Excel offers no p chart type; you build it from a line chart plus calculated columns for p, p-bar, UCL, and LCL.

What is the difference between a p chart and an np chart?

An np chart plots the number defective and requires a constant sample size. A p chart plots the proportion and works when sample sizes vary.

Can I use a p chart with a constant sample size?

Yes. With constant n the control limits become straight horizontal lines, and the chart is equivalent in interpretation to an np chart.

How many samples do I need before the limits are reliable?

Around 20–25 samples is the usual minimum; fewer than that and the estimated p-bar and limits are too unstable to judge the process.

Why is my lower control limit negative?

When p-bar is small or n is small, the calculated LCL falls below zero. Set it to 0 because a negative proportion defective cannot occur.

Can I build this in Excel for the web?

You can enter the formulas and insert a line chart, but formatting options are more limited than the desktop versions; for full control use Excel on Windows or Mac.