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

# Custom Measures

> Build your own metrics and KPIs in Upstack Analytics with a formula editor — combine revenue, spend, and order measures into custom ratios you can chart on any dashboard.

Custom measures let you define your own metric from a formula over the measures Upstack already tracks — without waiting on an engineering change. Combine revenue, spend, orders, and other measures with arithmetic to create the KPI your team actually reports on, such as net margin %, profit per order, or a blended efficiency ratio.

<Tip>
  A custom measure behaves exactly like a built-in measure. It respects the dashboard's filters, date range, comparison period, and granularity, and it picks up your cost adjustments — so the number stays consistent with the rest of your report.
</Tip>

## How custom measures work

A custom measure is a formula written over existing **base measures**. Upstack compiles that formula and computes it on the same engine that powers built-in ratio measures like ROAS and MER, so the result is calculated server-side against your data — not approximated in the browser.

For example, this formula defines your marketing efficiency ratio (MER) — total revenue earned per dollar of ad spend:

```text theme={null}
orders.total_revenue / channel.spend
```

Each operand (`orders.total_revenue`, `channel.spend`) is a base measure you select from a picker, so you never have to remember exact names. Set the format to **Multiplier** and the result displays as `3.2×`.

## Creating a custom measure

Custom measures are scoped to a single pixel and managed from a **custom dashboard**.

<Info>
  Creating, editing, and deleting custom measures is available to **admin and owner** roles, matching the permissions for cost settings. Viewers can still chart existing custom measures but won't see the management entry points.
</Info>

<Steps>
  <Step title="Open the Custom Measures dialog">
    On a custom dashboard, click **Custom Measures** in the dashboard toolbar. You can also open it from the **Manage custom measures** link next to the **Metric** field when adding or editing a widget.
  </Step>

  <Step title="Start a new measure">
    Click **+ New custom measure** to open the builder.
  </Step>

  <Step title="Name the measure">
    Enter a **Name** (e.g., `Marketing Efficiency Ratio`) and an optional **Short title** (e.g., `MER`) used where space is tight, such as chart legends and compact cards. Add an optional **Description** — it appears in the measure's tooltip.
  </Step>

  <Step title="Choose how it's formatted">
    Set the **Format** — Number, Currency, Percentage, or Multiplier — and the value displays accordingly across charts and summary cards.
  </Step>

  <Step title="Set the period total">
    Choose how the measure rolls up across the selected date range in the summary card:

    * **Sum** — adds each period's value (use for additive measures like revenue net of ad spend).
    * **Average** — recomputes the ratio over the whole period (use for ratios and percentages like MER or ad spend %).

    Upstack infers a sensible default from your formula; override it if needed.
  </Step>

  <Step title="Write the formula">
    Type your formula, using **Insert measure** to add base measures from a searchable, grouped picker. Validation runs as you type — a valid formula shows **Formula is valid.**, and errors explain what to fix.
  </Step>

  <Step title="Save">
    Click **Save**. The measure is enabled by default and immediately available in the measure picker. Use the eye icon in the list to disable a measure without deleting it.
  </Step>
</Steps>

## Writing formulas

Formulas support standard arithmetic over base measures and numeric constants:

| Element   | Allowed                                                                              |
| --------- | ------------------------------------------------------------------------------------ |
| Operators | `+`  `-`  `*`  `/`                                                                   |
| Grouping  | `(` `)`                                                                              |
| Numbers   | Literal constants (e.g., `100`, `0.3`)                                               |
| Operands  | Base measures inserted from the picker (e.g., `orders.net_revenue`, `channel.spend`) |

Some common patterns:

| Goal                             | Formula                                    | Format     |
| -------------------------------- | ------------------------------------------ | ---------- |
| Marketing efficiency ratio (MER) | `orders.total_revenue / channel.spend`     | Multiplier |
| Ad spend as % of net revenue     | `channel.spend / orders.net_revenue * 100` | Percentage |
| Net revenue after ad spend       | `orders.net_revenue - channel.spend`       | Currency   |
| Ad cost per order                | `channel.spend / orders.count`             | Currency   |

<Note>
  `orders.net_revenue` is net sales (after discounts and refunds) but **before** COGS and operating costs — so `orders.net_revenue - channel.spend` is revenue net of ad spend only, not true profit. To build a margin metric that reflects fulfillment and operating costs, include the relevant cost measures from the picker and make sure your [cost settings](/get-started/cost-settings) are configured.
</Note>

<Note>
  Division by zero returns 0, and any base measure with no data in a period is treated as 0. This keeps charts continuous instead of showing gaps or errors.
</Note>

## Using a custom measure on a dashboard

Once saved and enabled, a custom measure appears in the **Custom** group of the measure picker when you add or edit a widget on a custom dashboard. Select it like any built-in measure — it works with Metric, Sparkline, Bar, and Area chart types.

Because it runs on the same query path as built-in measures, the widget automatically reflects the dashboard's current filters, date range, comparison period, and granularity. No extra configuration is needed.

## What custom measures inherit

Custom measures reuse the standard query engine, so they pick up the same context as built-in measures automatically:

* **Filters** — applied per source so each operand is filtered correctly (an orders filter only affects orders measures, an ads filter only affects ad measures).
* **Date range, comparison period, and granularity** — threaded through unchanged.
* **Cost adjustments** — formulas that reference cost-adjusted measures are recomputed against your contribution-margin settings, matching how built-in cost measures behave. See [Cost settings](/get-started/cost-settings).

## Limitations

<Note>
  Custom measures are designed to behave like built-in measures, which sets a few boundaries in this version:

  * **Base measures only.** Operands must be measures available in the picker. You can't reference already-derived measures (such as ROAS or MER), attribution-only measures, or another custom measure.
  * **Not attribution-adjusted.** Like other non-attribution measures on the dashboard, custom measures are not adjusted by attribution model or window. For attribution analysis, use [Attribution reporting](/analytics/attribution-reporting).
  * **Custom dashboards only.** Custom measures are selectable on custom dashboards; they aren't yet available in other surfaces.
</Note>

## Related

<CardGroup cols={2}>
  <Card title="Measures & Dimensions" icon="ruler-combined" href="/data-dictionary/measures-and-dimensions">
    The base measures you build custom formulas from.
  </Card>

  <Card title="Query Guide" icon="magnifying-glass-chart" href="/analytics/query-guide">
    Build reports with measures, dimensions, and filters.
  </Card>

  <Card title="Cost Settings" icon="money-bill-trend-up" href="/get-started/cost-settings">
    Configure costs so margin-based custom measures are accurate.
  </Card>

  <Card title="Attribution Reporting" icon="chart-pie" href="/analytics/attribution-reporting">
    Compare attribution models and channel credit allocation.
  </Card>
</CardGroup>
