> ## Documentation Index
> Fetch the complete documentation index at: https://confidence.spotify.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Missing Values

> Configure how Confidence handles entities without measurements in your experiment metrics.

It's common that some of your users don't have measurements. For example, if you measure
the time it takes to load a particular part of your app, a user who never visits that part
has a missing value. This section describes how to handle missing values in Confidence.

## Configure How to Treat Missing Values

In general, there are many ways to handle missing values. For example, you can discard them, replace
them with a specific value, or impute them based on values of other similar users. The best approach
generally depends on what you want to measure. For example, if you measure latency, it's
sensible to just discard the users with missing values. If you measure the minutes of
music played, then users with missing values have played zero minutes of music.

Confidence allows you to configure how to handle missing values for users, or entities, more
generally. By default, Confidence replaces missing values with zero if you are using the `SUM`,
`COUNT` or `COUNT_DISTINCT` aggregations. For other aggregations, Confidence discards users with
missing values by default. You can override this behavior in the **Missing Values** section of a
metric, see below.

<img src="https://mintcdn.com/confidence-7c0fec1b/KTPKB6kyq9KGua3d/images/missing-values-config.png?fit=max&auto=format&n=KTPKB6kyq9KGua3d&q=85&s=51c3d367feba137acde6f7b0c515a8f3" alt="Configuring Missing Values" width="476" height="142" data-path="images/missing-values-config.png" />

<Note>
  Discarding users with missing values can lead to [sample ratio mismatch](../monitoring) for a specific metric.
  For example, if the treatment increases the chance that a user visits a particular part of the
  app that you want to measure, then the treatment group has fewer users with missing
  values than the control group. Because of the sample ratio mismatch, the two
  groups might no longer be comparable. In this situation, a bias in which users are included in each group's
  metric value can drive the significant differences you detect.
</Note>

If you want further control over how to handle missing values, you can replace them directly in
the SQL query for the fact table. For example, if you want to replace missing values with a 1
instead of a zero, you can define the measurement column `IFNULL(measurement, 1)` instead of just
passing `measurement` to Confidence.

## Missing Values and Variance Reduction

Confidence estimates the parameters required for variance reduction on the subset of users that
have both a pre-exposure and post-exposure measurement. If this subset of users is a small part of all users
then Confidence disables variance reduction.

## Missing Values and Ratio Metrics

Confidence discards all rows in the fact table that have a missing value for the numerator or
denominator to ensure consistency. If you don't want this behavior, then you can replace
the missing values directly in the SQL query for the fact table.

## Related Resources

<CardGroup cols={2}>
  <Card title="Fact Tables" href="/docs/metrics/fact-tables">
    Configure fact table SQL queries
  </Card>

  <Card title="Variance Reduction" href="/docs/experiments/stats/variance-reduction">
    Improve metric precision
  </Card>

  <Card title="Monitoring" href="/docs/experiments/monitoring">
    Detect sample ratio mismatches
  </Card>

  <Card title="Metrics Reference" href="/docs/metrics/metrics">
    Configure metric aggregations
  </Card>
</CardGroup>
