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

# Custom Metrics

> Define SQL-based custom metrics at the table and column level to track aggregate values alongside built-in profiler metrics.

# Custom Metrics

Custom metrics let you define SQL-based metrics that the profiler computes alongside built-in system metrics. Add them at the table level to track aggregate values across rows, or at the column level to measure values for a specific column. Computed results appear in the **Table Profile** and **Column Profile** tabs after the Profiler Agent runs.

## Table-Level Metrics

Table-level metrics track a custom aggregate value computed across all rows in a table.

1. In the table's details page, navigate to the **Data Observability** tab and click **Table Profile**.

2. Click **Add** and select **Custom Metric**.

   <img src="https://mintcdn.com/collatedocs/kIcf12aq0fGgWkOd/public/images/ai-2.0/data-observability/data-profiler/select-table-metrics.png?fit=max&auto=format&n=kIcf12aq0fGgWkOd&q=85&s=d4299ddd9441b25745b75b4ffd57dbbc" alt="Select Add Custom Metric" width="2784" height="1168" data-path="public/images/ai-2.0/data-observability/data-profiler/select-table-metrics.png" />

3. In the **Add Table metric** form, fill in the following required fields and click **Create**:

   * **Name**: A unique descriptive name for this metric.
   * **SQL Query**: A SQL expression that returns a single numeric value. The result appears as a custom metric under **Data Volume** on the **Table Profile** tab.

   <img src="https://mintcdn.com/collatedocs/kIcf12aq0fGgWkOd/public/images/ai-2.0/data-observability/data-profiler/add-table-metrics.png?fit=max&auto=format&n=kIcf12aq0fGgWkOd&q=85&s=0be405dcde61b0e5799ed235ac08739e" alt="Input SQL query" width="2772" height="1204" data-path="public/images/ai-2.0/data-observability/data-profiler/add-table-metrics.png" />

4. After the custom metric is added, navigate to the database service and run the **Profiler Agent** from the **Agents** tab.

   <img src="https://mintcdn.com/collatedocs/kIcf12aq0fGgWkOd/public/images/ai-2.0/data-observability/data-profiler/run-profiler-agent.png?fit=max&auto=format&n=kIcf12aq0fGgWkOd&q=85&s=9664c5eb8de7de546db9ed9206177c51" alt="Run Profiler Agent" width="2754" height="1180" data-path="public/images/ai-2.0/data-observability/data-profiler/run-profiler-agent.png" />

5. After the run is completed, return to the table to view the computed custom metric on the **Table Profile** tab.

   <img src="https://mintcdn.com/collatedocs/kIcf12aq0fGgWkOd/public/images/ai-2.0/data-observability/data-profiler/view-table-cs-metrics.png?fit=max&auto=format&n=kIcf12aq0fGgWkOd&q=85&s=4a96e77e987aa0d803281af8c5aa4488" alt="View Custom Metric" width="3760" height="1686" data-path="public/images/ai-2.0/data-observability/data-profiler/view-table-cs-metrics.png" />

## Column-Level Metrics

Column-level metrics track a custom value computed for a specific column in a table.

1. In the table's details page, navigate to the **Data Observability** tab and click **Column Profile**.

2. Click **Add** and select **Custom Metric**.

   <img src="https://mintcdn.com/collatedocs/kIcf12aq0fGgWkOd/public/images/ai-2.0/data-observability/data-profiler/select-column-metrics.png?fit=max&auto=format&n=kIcf12aq0fGgWkOd&q=85&s=048c78548c57551f18d8e8ff4382beca" alt="Select Add Custom Metric" width="2760" height="1164" data-path="public/images/ai-2.0/data-observability/data-profiler/select-column-metrics.png" />

3. In the **Add Column metric** form, fill in the following required fields and click **Create**:

   * **Name**: A unique descriptive name for this metric.
   * **Column**: The column this metric applies to. Select from the dropdown list of columns in the table.
   * **SQL Query**: A SQL expression that returns a single numeric value for the selected column. The result appears as a custom metric under **Data Counts** on the **Column Profile** tab.

   <img src="https://mintcdn.com/collatedocs/kIcf12aq0fGgWkOd/public/images/ai-2.0/data-observability/data-profiler/add-column-metrics.png?fit=max&auto=format&n=kIcf12aq0fGgWkOd&q=85&s=ba8629e72c935118bd1d60f5202fb270" alt="Input SQL query" width="2804" height="1384" data-path="public/images/ai-2.0/data-observability/data-profiler/add-column-metrics.png" />

4. After the custom metric is added, navigate to the database service and run the **Profiler Agent** from the **Agents** tab.

   <img src="https://mintcdn.com/collatedocs/kIcf12aq0fGgWkOd/public/images/ai-2.0/data-observability/data-profiler/run-profiler-agent.png?fit=max&auto=format&n=kIcf12aq0fGgWkOd&q=85&s=9664c5eb8de7de546db9ed9206177c51" alt="Run Profiler Agent" width="2754" height="1180" data-path="public/images/ai-2.0/data-observability/data-profiler/run-profiler-agent.png" />

5. After the run is completed, return to the table to view the computed custom metric on the **Column Profile** tab.

   <img src="https://mintcdn.com/collatedocs/kIcf12aq0fGgWkOd/public/images/ai-2.0/data-observability/data-profiler/view-column-cs-metric.png?fit=max&auto=format&n=kIcf12aq0fGgWkOd&q=85&s=6837c08a96aa025c988fa169e25886d7" alt="View Custom Metric" width="4024" height="1911" data-path="public/images/ai-2.0/data-observability/data-profiler/view-column-cs-metric.png" />
