# Metrics

A metric is a calculation that summarises many rows into one value, such as the number of visits, the conversion rate or revenue.
Metrics are calculated when your query runs, from the latest data in your explores.

Select a metric on its own and you get one number for the whole explore, after any filters.
Add dimensions and the metric is calculated separately for each row of your results, such as each channel or each week.

In the Explorer, metrics are listed under **Metrics** in the field list, and shown in orange in the results table.
Hover over one to read its description, which says exactly what it counts.

## How metrics are calculated

Every metric has a type, which sets how it summarises the rows.

| Type | What it calculates | Examples |
| --- | --- | --- |
| Count | The number of rows | Visits, Purchases |
| Count distinct | The number of different values | Users, Countries |
| Sum | The total of the values | Revenue, Conversions, Orders |
| Average | The mean of the values | Pages per visit |
| Median | The middle value | Median days to convert |
| Percentile | The value below which a given share of values fall | LCP, 75th percentile (s), in the Page views explore |
| Min and max | The smallest or largest value | Last visit |
| Ratio | One metric divided by another, in each row | Conversion rate, Average order value, Revenue per visit |

Median and percentile metrics are approximations, which your warehouse calculates quickly over millions of rows.
They can differ very slightly from an exact calculation.

### Metrics that count some rows

Many metrics only count the rows that meet a condition.
**Converting visits** counts the visits that converted, and **Purchases** counts the visits with a purchase.
Ratios are built from them: **Conversion rate** is **Converting visits** divided by **Visits**, worked out in each row of your results.

### Metrics that do not add up

Counts and sums add up across rows: visits per channel add up to all visits.
Distinct counts do not.
**Users** counts each visitor once, so someone who visits in three different weeks counts once in each week, but only once in the month.
Ratios and medians do not add up either, so read them row by row.

## Use metrics in the Explorer

- To filter on a metric, open its menu in the field list and select **Add filter**.
  A filter on a metric removes rows from your results after the metric is calculated, for example channels with fewer than 100 visits.
- Select a metric value in the results table, then **View underlying data** to see the rows behind it, or **Drill into** to break it down by another dimension.
- To compare a metric with an earlier period, open its column menu in the results table and select **Add period comparison**.
  This adds a column with the metric for the period before, such as the previous week.
  Your query needs a date dimension, and the feature is in beta.

## Custom metrics

A custom metric adds a metric to your chart without changing the explore.
It is saved with the chart, listed under **Custom metrics** in the field list, and does not change the explore for anyone else.

### From a dimension

1. In the field list, hover over a dimension and select the three dots.
2. Under **Add custom metrics**, choose a calculation, such as **Average** or **Count distinct**.
3. Check the **Label** and select **Create**.
   To set a format or add a filter, select **More options** first.

The calculations on offer depend on the dimension's type.

| Dimension type | Calculations |
| --- | --- |
| Number | Sum, Average, Median, Percentile, Min, Max, Count, Count distinct |
| String, date and timestamp | Count, Count distinct, Min, Max |
| Boolean | Count, Count distinct |

For example, **Average** of **Pages in visit** gives the average pages per visit, and **Count distinct** of **Landing page** gives the number of different landing pages.

### From a metric

To make a variation of an existing metric, such as **Revenue** for one channel only, select **Create custom metric** in the metric's menu, in the field list or the results table.
This makes a copy you can rename and add filters to.
It works for count, count distinct, sum, average, min, max, median and percentile metrics.

## Table calculations

Table calculations work on the results of your query, like formulas in a spreadsheet.
Use them for calculations that look across rows, such as a share of the total, a running total, a rank or the change from the previous row.
They are shown in green in the results table.

### Quick calculations

Open a metric's column menu in the results table, select **Add quick calculation** and choose one:

- **Percent change from previous**
- **Percent of previous value**
- **Percent of column total**
- **Rank in column**
- **Running total**

The new column is named after the calculation and the metric, such as **Percent of column total of Visits**, and opens for editing straight away.
**Rank in column** works with any metric; the others need a numeric metric other than min or max.

### Write a formula

1. In the **Results** panel, select **Table calculation**.
2. Write a formula, typing `@` to use a field from your query and `#` to find a function, for example `=IF(@Visits > 1000, "high", "low")`.
3. Give the calculation a **Name**, choose its format and select **Create formula**.

### Table calculation or metric?

A table calculation only exists in its chart and can only use the fields in your query.
A metric is defined once and gives the same number in every chart and dashboard.
If you find yourself rebuilding the same calculation, [contact us](/docs/support/contact-us) to ask for it as a metric.

## Find metrics in the Metrics Catalog

Select **Metrics** in the top bar to open the **Metrics Catalog**, which lists the metrics in your explores with their descriptions.
Select a metric to open it in the Metrics Explorer, where you can follow it over time, change the granularity, and filter or segment it by a dimension.
Admins can tag metrics with categories to organise the catalog.

## Related

- [How explores, dimensions and metrics work](/docs/analytics/explores-dimensions-and-metrics): the three building blocks and how they fit together.
- [Explores](/docs/analytics/explores): build a query and dig into its results.
- [Dimensions](/docs/analytics/dimensions): what your metrics are grouped and filtered by.
