---
title: Write formulas in Metric Explorer
description: "Combine Metric Explorer metrics with arithmetic, including hybrid formulas that mix event and session inputs such as revenue per session, and save formulas as reusable metrics."
product: analytics
lang: en
last_updated: 2026-10-27
token_estimate: 1327
---
# Write formulas in Metric Explorer

> For AI agents: a documentation index is available at [/docs/llms.txt](/docs/llms.txt). Append `.md` to any page URL for markdown, or send `Accept: text/markdown`.

A formula in Metric Explorer is arithmetic on other metrics in the same chart, such as `A/B` for a ratio or `(A+B)/C` for a combined rate. Each input keeps the measurement, filters, and group-bys set on its own metric, so the formula itself stays short. A formula that mixes an event metric and a session metric is a hybrid formula, for example revenue per session or add-to-carts per session.

## Write a formula

1. Add the metrics the formula uses, for example `Page Viewed` measured as **Event Totals** and `[Amplitude] Any Active Event` measured as **Total Sessions**.
2. Click **fx**. A **Formula** card appears in the **Metrics** block.
3. Enter the expression using the metric letters, for example `A/B`.
4. Optional: click **Name formula** in the formula's **⋮** menu and enter a name, such as `Pages per session`. The name replaces the expression in the legend and breakdown table.

Amplitude hides the metrics a formula refers to, so the chart shows the formula's result. To show an input next to the formula, open that metric's **⋮** menu and click **Show in results**.

## Formula syntax

- **Letters**: Each metric in the **Metrics** block has a letter by position: A, B, C, and so on. Formulas and session metrics take letters too, so a metric added after a formula in position C becomes D.
- **Operators**: Use `+`, `-`, `*`, `/`, and parentheses, for example `(A+B)/C`.
- **Percentages**: Start the formula with `%:` to display the result as a percentage, for example `%:A/B` for a conversion rate.
- **Segments**: With more than one segment, add the segment number after the letter. `A2/A1` divides metric A in segment 2 by metric A in segment 1.

Measurements come from each metric, not from functions in the formula. Where an Event Segmentation formula reads `UNIQUES(A)/TOTALS(B)`, a Metric Explorer formula reads `A/B`, with A measured as **Unique Users** and B as **Event Totals**. For smoothing, set **Rolling Average**, **Rolling Window**, or **Cumulative** on an event metric from its **⋮** menu.

## Hybrid formulas

A hybrid formula combines event inputs and session inputs in one expression. Use one when the question relates actions to visits:

| Goal | Inputs | Expression |
| --- | --- | --- |
| Revenue per session | A: `Purchase` measured as **Revenue**. B: `[Amplitude] Any Active Event` measured as **Total Sessions**. | `A/B` |
| Add-to-carts per session | A: `Add to Cart` measured as **Event Totals**. B: **Total Sessions** of all sessions. | `A/B` |
| Pages per session | A: `Page Viewed` measured as **Event Totals**. B: **Total Sessions** of all sessions. | `A/B` |
| Sessions per user | A: **Total Sessions** of all sessions. B: `[Amplitude] Any Active Event` measured as **Unique Users**. | `A/B` |

A formula can also divide two session metrics. For example, the share of sessions with a purchase is `%:A/B`, where A is `Purchase` measured as **Total Sessions** and B is **Total Sessions** of all sessions.

Inputs keep their own filters, so a hybrid formula can compare a filtered event with all sessions. For example, divide revenue where `plan` is `pro` by all sessions.

Hybrid formulas run in Metric Explorer and in Data Tables, and you can save them as metrics for either.

### Create a hybrid formula in a Data Table

1. In a Data Table, open the **Metrics** tab and click **+ Define new Metric**.
2. Choose **Hybrid Formula** as the metric type.
3. Add event and session inputs. Each input has a letter and its own **Measured as**.
4. Enter the expression, for example `A/B`.
5. Click **Save and Close**.

For other metric types in Data Tables, go to [Create a metric](https://amplitude.com/docs/analytics/charts/data-tables/data-tables-create-metric).

## Filters and group-bys with formulas

A formula uses the filters and group-bys of its inputs. To break a formula down by a property, add the same group-by to each input. The formula then renders one series per value. For session inputs, the group-by also chooses which session value to use. Go to [Group sessions by entry, exit, or any value](https://amplitude.com/docs/analytics/charts/metric-explorer/metric-explorer-analyze-sessions#group-sessions-by-entry-exit-or-any-value).

In Data Tables, global filters apply to both event and session inputs of a hybrid formula. For session columns, go to [Use session metrics in Data Tables](https://amplitude.com/docs/analytics/charts/data-tables/data-tables-use-session-metrics).

## Save a formula as a metric

Save a formula as a metric to reuse it in other Metric Explorer charts and Data Tables and to keep one definition across your team.

1. On the formula, or on any metric, open the **⋮** menu and click **Save as Metric**. To save the whole chart as one metric, open **More** above the chart and click **Save as Metric**.
2. Review the metric definition. A formula with event and session inputs saves as a **Hybrid Formula** metric.
3. Name the metric and save it.

The saved metric appears in the metric picker of Metric Explorer and Data Tables. For managing saved metrics, go to [Metrics](https://amplitude.com/docs/analytics/metrics).

