Anomaly detection in Power BI line charts

How anomaly detection in Power BI finds unusual points in a line chart's time series, the expected range and sensitivity, explanations with Explain by fields, the requirements (time axis, one value, four points), and a DAX check for the same idea.

Short answer: anomaly detection marks the points of a line chart that fall outside an expected range the algorithm learns from the series itself, and draws that range as a band. Turn it on in the Analytics pane of a line chart with a time axis. The sensitivity decides how wide the band is: higher sensitivity flags more points. Select an anomaly and Power BI looks for explanations across the fields of the model, or only those you put in Explain by. It needs one measure, no legend, and at least four points.

A spike in daily revenue might be a campaign, a pricing error or a bot. Spotting it in a 365-point line is easy when it is huge and hard when it is merely unusual for a Tuesday in March. Anomaly detection judges each point against the pattern of the series, including its seasonality.

What does it look like?

0100200300400500123456789101112
Daily orders; day 9 falls far below the range of the other days

In Power BI the band is shaded around the line and the anomaly is a marker. Hover it to see the value, the expected value and the range; select it for explanations.

How do you turn it on?

  1. Build a line chart with a date on the X-axis and one measure on the Y-axis.
  2. Open the Analytics pane (the magnifier icon) and Find anomalies, Add.
  3. Set the Sensitivity: a higher value narrows the expected range, so more points count as anomalies.
  4. Format the anomaly marker (shape, size, colour) and the expected range (colour, style, transparency).
  5. For explanations, drag fields such as Store[City] or Product[Seller] into Explain by; select an anomaly and the pane lists the factors that best explain the jump or dip, with a chart for each.

What are the requirements?

Microsoft lists them:

  • Only line charts with time series data on the axis.
  • No legend, no multiple values, no secondary values in the chart.
  • At least four data points.
  • Forecast, Min, Max, Average, Median and Percentile lines do not work together with anomaly detection.
  • Not supported for DirectQuery over SAP, Power BI Report Server, or live connections to Azure Analysis Services or SQL Server Analysis Services.
  • Explanations do not work with "Show value as" options, and drilling down to the next hierarchy level is not supported.

Can you flag anomalies with DAX?

For a rule people can read (and use in tables, alerts and tooltips), a simple version compares each day with the average and spread of the previous four weeks:

Orders = DISTINCTCOUNT ( Sales[Order ID] )

Orders Expected =
AVERAGEX (
    DATESINPERIOD ( 'Date'[Date], MAX ( 'Date'[Date] ) - 1, -28, DAY ),
    [Orders]
)

Orders Spread =
STDEVX.S (
    DATESINPERIOD ( 'Date'[Date], MAX ( 'Date'[Date] ) - 1, -28, DAY ),
    [Orders]
)

Orders Unusual =
VAR Z = DIVIDE ( [Orders] - [Orders Expected], [Orders Spread] )
RETURN IF ( ABS ( Z ) > 3, "Unusual", "Normal" )

A day more than three standard deviations from the last four weeks' average is flagged. It ignores weekly patterns (Saturday is always lower); compare with the same weekday instead when the week shapes the data. The built-in detection handles seasonality for you; the DAX rule is transparent and works anywhere.

What goes wrong?

  • A legend on the chart. The Find anomalies option disappears; one measure, no legend.
  • Too sensitive. Every third point flagged teaches people to ignore the markers. Lower the sensitivity until flags are rare.
  • Explanations taken as causes. "City is Graz" explains the dip statistically; the cause still needs a person to look.
  • Incomplete last day. Today's partial data is always "low". Stop the series at yesterday.

Where can you check this?

Where do you start?

Turn on Find anomalies on one daily line chart, lower the sensitivity until only real surprises show, and add three or four Explain by fields. Line charts cover the chart itself, and the Analytics pane its other lines.

Keep reading

More from the blog.

Every post

Next

Building this? Say hello.

A question about this post, a pattern you would build differently, or the next thing you want written out: Behnia reads every message.