

Anomaly detection for business metrics: compare Monday with Mondays
Anomaly detection is the practice of finding values that differ from what is expected, such as a day when cancellations jump or orders fall to zero. For a business metric, "expected" depends on the weekday, the season, and the size of the segment, so each day belongs beside a baseline of days like it. Set thresholds the metric's owner will act on, and check the data and the drivers before anyone acts on an alert.
The case at the center of this post is a subscription service whose cancellation alert fires on an ordinary Monday and stays quiet on an unusual Wednesday. The service and its counts are fictional, and no customer's data went into them.
Point, contextual, and collective anomalies
IBM defines anomaly detection as identifying observations, events, or data points that deviate from what is usual, standard, or expected. For time series data, meaning values recorded over time, it names three types:
- A point anomaly is one value far outside the rest, such as a withdrawal much larger than any the account has made before.
- A contextual anomaly is unusual only in its context. IBM's example is a jump in a home's energy use at midday, when nobody is usually home.
- A collective anomaly is a group of values that together depart from the norm, even when each one looks ordinary.
Most alerts on business metrics are contextual. A count that is normal for a Monday can be strange for a Wednesday.
IBM also separates anomalies caused by errors in data collection from those caused by real events. That split sets the first move after any alert: rule out a data problem, then look for a business cause.
How each method decides what "expected" means
Every method asks how far today is from expected. They differ in how they build the expected value.
| Method | How it works | Fits | Watch for |
|---|---|---|---|
| Fixed threshold | Alerts when the value crosses a set line | Hard limits, such as zero orders or a contractual cap | Ignores weekday and seasonal patterns |
| Change from the same day last week | Compares today with one earlier day of the same type | Quick checks on metrics with a weekly pattern | One unusual prior day distorts the baseline |
| Z-score | Measures distance from the mean in standard deviations | Stable metrics with no weekly or seasonal pattern | Patterns and outliers inflate the standard deviation |
| Modified z-score | Measures distance from the median, scaled by the median absolute deviation | Short histories with occasional outliers | Needs a like-for-like baseline, such as the same weekday |
| Forecast interval | A model predicts an expected range, and values outside it are flagged | Metrics with trend, seasonality, and known events | Needs enough history and periodic retraining |
| Machine learning | Models such as isolation forest learn what normal looks like across many variables | Many metrics or dimensions at once | Harder to explain why a value was flagged |
The NIST/SEMATECH e-Handbook of Statistical Methods defines the z-score as an observation's distance from the sample mean in sample standard deviations. It warns that z-scores can mislead, particularly for small samples. The handbook then gives the modified z-score recommended by Iglewicz and Hoaglin: 0.6745 times the distance from the median, divided by the median absolute deviation (MAD), which is the median of each value's absolute distance from the median. Those authors recommend labeling values with an absolute modified z-score above 3.5 as potential outliers.
Forecast intervals now ship as built-in warehouse functions. BigQuery ML's ML.DETECT_ANOMALIES flags a time series value when its anomaly probability exceeds a threshold, 0.95 by default, and a larger threshold widens the interval. Snowflake's anomaly detection function forecasts the period under review and flags values outside a prediction interval, 0.99 by default. It accepts extra variables such as holidays and advertising campaigns. IBM's page lists isolation forest, one-class support vector machines, and local outlier factor among common machine learning methods.
A cancellation alert that fired on the wrong day
The service counts cancellations on the day it processes them. Requests made over the weekend are processed on Monday, so Mondays run high and weekends run low. The team's alert compares each day with the mean of the last six weeks and fires when the z-score exceeds 2.
Table 1: daily cancellations, six weeks of history and the test week.
| Week | Mon | Tue | Wed | Thu | Fri | Sat | Sun |
|---|---|---|---|---|---|---|---|
| 1 | 178 | 124 | 118 | 121 | 115 | 72 | 66 |
| 2 | 185 | 119 | 123 | 117 | 120 | 68 | 70 |
| 3 | 172 | 127 | 120 | 125 | 112 | 75 | 64 |
| 4 | 181 | 121 | 126 | 119 | 118 | 70 | 69 |
| 5 | 176 | 118 | 117 | 122 | 116 | 74 | 67 |
| 6 | 188 | 125 | 122 | 120 | 121 | 69 | 71 |
| Test | 190 | — | 150 | — | — | — | — |
Over the 42 history days, the mean is 114.3 and the sample standard deviation is 35.4. The swing between Mondays and weekends accounts for much of that spread.
- Test Monday: (190 - 114.3) ÷ 35.4 = 2.14. The alert fires. It would also have fired on the ordinary Monday of week 6, at 2.08.
- Test Wednesday: (150 - 114.3) ÷ 35.4 = 1.01. No alert.
A fixed line fails the same way. Wednesday's 150 is below every Monday in the history, which ran from 172 to 188, so any single line low enough to catch 150 also fires every Monday.
Compare each day with its own weekday instead, using the modified z-score.
Table 2: same-weekday baseline over six weeks.
| Day | Six-week history | Median | MAD | Test value | Above median | Modified z-score |
|---|---|---|---|---|---|---|
| Monday | 178, 185, 172, 181, 176, 188 | 179.5 | 4.5 | 190 | 10.5 | 0.6745 × 10.5 ÷ 4.5 = 1.57 |
| Wednesday | 118, 123, 120, 126, 117, 122 | 121.0 | 2.5 | 150 | 29.0 | 0.6745 × 29.0 ÷ 2.5 = 7.82 |
Against other Mondays, the test Monday is unremarkable. Wednesday is far outside its own history, a contextual anomaly in IBM's terms. Run the same rule over the six history weeks, holding out each day in turn and scoring it against the other five of its weekday, and it flags none of the 42 days. Six values per weekday is a short history, so that backtest is a sanity check and proves little about the false-alarm rate.
An alert says that something moved. To learn what moved, split Wednesday by cancellation reason and set it against the average of the last six Wednesdays, which is also 121.
Table 3: Wednesday cancellations by reason.
| Reason | Six-Wednesday average | Test Wednesday | Change |
|---|---|---|---|
| Price or value | 38 | 40 | +2 |
| Moving or no longer needed | 30 | 31 | +1 |
| Payment failed | 22 | 47 | +25 |
| Service problem | 18 | 19 | +1 |
| Other | 13 | 13 | 0 |
| Total | 121 | 150 | +29 |
Failed payments account for 25 of the 29 extra cancellations, or 86% of the change. The next check belongs with billing: a failed retry run, a change at the payment processor, or a batch of expired cards. So far nothing shows that customers want the service less. Gravity's guide to AI root cause analysis covers the general method for splitting a change by its drivers.
Choosing a threshold the owner will read
Every threshold sets how many alerts a person will read and act on. Choose it with the metric's owner, base it on history, and write it down.
- Backtest before launch. Run the rule over the past year and count the days it would have flagged. Go through each one with the owner and mark it as a real event, a data problem, or noise.
- Pair the statistical test with a business floor. In this case, alert only when the modified z-score exceeds 3.5 and the day is at least 20 cancellations above its median. A small segment can be statistically odd and still not worth anyone's morning.
- Decide the direction for each metric. A drop in orders and a rise in cancellations both need alerts. A rise in orders may need only a note.
- Set a minimum volume, below which percentage swings are noise.
- Keep a calendar of known events, such as holidays, price changes, and billing runs, and decide whether the alert should allow for each one.
- Review the threshold every quarter against the record of which alerts turned out to be real.
Five checks, in order, after an alert
Run the checks in the same order every time, and log each result, including the checks that found nothing.
- Confirm the data. Make sure the day loaded completely, that no rows were duplicated, and that the metric's definition did not change. This is IBM's split between collection errors and real events, put to work.
- Look at the calendar. Compare the day with known events: a release, a campaign, a price change, a billing run.
- Find the drivers. Split the change by the dimensions the team acts on, such as reason, plan, region, and channel, and name the group that carries most of it.
- Route the finding. Send it to the owner of that group with the evidence and one proposed next check.
- Label the alert as real, a data problem, or noise, so that the next threshold review has a record to work from.
For a cancellations metric, define the churn event before you monitor it. Gravity's churn analysis, worked through an example, shows how.
Handing the morning checks to Orion
Plenty of tools raise the flag itself. Power BI data alerts notify users when dashboard data changes beyond limits they set, which suits fixed thresholds. BigQuery ML and Snowflake run forecast-interval detection inside the warehouse, next to the data. A notebook suits a one-off investigation that a single analyst owns. A team that needs only the flag is well served by any of them.
Orion, the analytics platform, takes on the data checks and the driver split that follow the flag, and runs them the same way each morning. The team supplies the rules: the same-weekday baseline, the 3.5 and 20-cancellation thresholds, the data checks to run first, and the owner of each cancellation reason. Orion holds them in Context pages.
An analyst could start the daily cancellation check with one message in chat: "Using the cancellation definition in our Context page, compare yesterday's cancellations with the same weekday over the last six weeks. Show the median, the MAD, the modified z-score, and the count above the median. If the modified z-score is above 3.5 and the count is at least 20 above the median, confirm that yesterday's data loaded completely, then split the change by cancellation reason, plan, and signup channel, and name the group that carries most of it. Show the SQL."
What the tables cannot tell it, Orion asks. Its Observatory cards put questions to the people who can edit the project, such as what caused a given spike, and record the answer for the next review. When an answer adds something new, such as the dates of the billing retry runs, a Context card proposes the edit for an editor to apply or dismiss. The cards also suggest analyses worth a look, such as failed payments split by card type whenever that reason jumps.
The analyst can open the check as an analysis notebook, read its SQL and Python, and check its medians and MADs by hand on a few days. Once it matches, the team can ask Orion for a daily Workflow built from it. Orion runs a full trial of the Workflow before saving it, and it goes live only with the team's approval. From then on, each morning's run names the drivers behind any day that clears both thresholds, along with the owner of each. A telecom operator, for one, runs daily Orion checks that alert on unusual disconnects and confirm that subscriber records agree between its systems.
Picking the first metrics to watch
Start with the five metrics whose moves cost the business most when nobody notices them for a week. For each, agree on the baseline, the statistical threshold and the business floor, the data checks to run first, and the owner of each driver. Then backtest the rule on last year's data before it sends a single alert.
In the case above, the Monday alert was noise and the Wednesday move was real, with failed payments behind 86% of the extra cancellations. The decision left for the review is who owns failed payments, and what that person checks first the next time the number moves.