---
updatedAt: 2026-11-03T00:00:00.000Z
agentTools:
  projectIndex: https://docs.getmontecarlo.com/llms.txt
---

# Custom Metrics

In [Metric Monitors](https://docs.getmontecarlo.com/docs/metric-monitors) and [Comparison Monitors](https://docs.getmontecarlo.com/docs/comparison-rules), users can define custom metrics using SQL. Defining a custom metric is helpful when:

* **The desired metric isn't one of the[available metrics](https://docs.getmontecarlo.com/docs/available-metrics).** For example:
  * `APPROX_PERCENTILE(order_amount, 0.99)`. This metric measures the 99th percentile of order\_amount. While there is an available metric for 80th percentile, there is not 99th, and so a custom metric is needed.
* **The user needs to references multiple fields in the metric.** For example:
  * `AVG(price + tax_collected)`: this metric measures the average value of price plus tax\_collected.
  * `COUNT(DISTINCT(CONCAT(invoice_number, line_item)))/COUNT(*)`: this metric measures the uniqueness (%) of the concatenation of invoice\_number and line\_item.

To add a custom metric, select **Custom** in the metric dropdown in the **Define alert conditions** section of the monitor.

In a Metric Monitor, provide a metric name and a SQL expression, then test the metric to confirm it works.

<Image align="center" width="500px" src="https://files.readme.io/38e1311-Pasted_Image_5_2_24__11_20_PM.png" />

<br />

In a Comparison Monitor, provide a metric name and a SQL expression for source and target, then test each metric to confirm they work.

<Image align="center" width="500px" src="https://files.readme.io/62db27168aeb2c4a1d3fc1f9232ec05d6341c9291b83feabb88e1aa9ab51ed09-custom.png" />