The Baresquare anomaly detection algorithm creates an expected interval (min and max expected values) for any monitored KPI/metric and for every single combination of dimensions. Check also this article to learn more about how this works behind the scenes.

## The 'vs. expected value' comparison

An indication of the magnitude of each reported anomaly is depicted on the '*vs expected value*' comparison, which shows **how much the actual value of the metric at hand deviated from the expected interval**. This comparison is visible for both the key and the (co)related metrics if any:

The 'vs expected value' is a dynamic comparison, calculated as follows:

if the actual value of the metric is

**above**the expected interval, then it's the distance of the actual value from the max expected value.

โif the actual value of the metric is

**below**the expected interval, then it's the distance of the actual value from the min expected value.

โif the actual value of the metric is

**within**the expected interval, then it's the distance of the actual value from the expected value, which is the midpoint of the min and max expected values.

It's important to note that **the 3rd case is only applicable to (co)related metric**s. A key metric will always be either above or below the expected interval since this is a necessary and sufficient condition for a ticket to be created in the first place.

## Additional 'vs.' comparisons

Baresquare compares the key and correlated metrics against other (base) values, too: vs. the previous day, vs. the same day last week, vs. the average of the last 4 weeks, and vs. the same day last year. The calculation logic is the same, i.e., the actual value is compared against the base value(s).

When the actual value refers to a numeric or currency metric (such as 'Entrances' or "Revenue"), the vs. expected calculation results in a **percentage difference** (e.g., +42.3%).

If the base value is 0, the percentage difference cannot be calculated, due to a division by zero error. In these cases, the **absolute difference** is shown instead (e.g., +5).

When the actual value refers to a percentage metric (such as 'Bounce rate'), the vs. expected calculation results in the **percentage points difference** (e.g., +0.23 p.p.).

If the base value is not available for any reason, the "n/a" value is shown.