# How to Create a Dynamic Reference Line

**URL:** <https://community.omni.co/t/how-to-create-a-dynamic-reference-line/385>\
**Category:** Visualizations\
**Tags:** dashboards, filtering\
**Created:** [August 13, 2025, 7:06pm UTC](https://community.omni.co/t/how-to-create-a-dynamic-reference-line/385 "2025-08-13T19:06:46Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![samp](https://yyz2.discourse-cdn.com/flex004/user_avatar/community.omni.co/samp/32/520_2.png) [@samp](https://community.omni.co/u/samp)\
**Post date:** [August 13, 2025, 7:06pm UTC](https://community.omni.co/t/how-to-create-a-dynamic-reference-line/385/1 "2025-08-13T19:06:46Z")

</div>

## Overview

Omni doesn’t currently offer a built-in “dynamic reference line” feature, but you can achieve the same effect with a simple workaround. This approach lets you set a margin target and switch between different target values directly from your dashboard using a **Field Swapper**.

## Example Use Case

You have a monthly margin chart and want to compare it against a target. Instead of hardcoding one static target, you want to dynamically change the target based on user selection.

* * *

## Steps

### 1. Create a Target Table

- Create a **blank table** in Omni.
- Manually enter your target values and assign each a target name.

**Example:**

| Target Name | Target Value |
| --- | --- |
| Target A | 158 |
| Target B | 140 |
| Target C | 175 |

- Save the table as **`targets`** (or similar) and open it in the Query view.

* * *

### 2. Promote Fields to Workbook

- Create three separate columns: **Target A** , **Target B** , and **Target C**.
- **Promote all columns** to the workbook so they can be referenced later.
- Remove the extra columns from your query (you only need them in the workbook, not in this table’s results).

* * *

### 3. Create a Target Margin Column

- In your main dataset, add a new column called **Target Margin**.
- Use an **XLOOKUP** to pull the correct target value:

```sql
=XLOOKUP(
  C1, 
  'targets'!A:A, 
  'targets'!B:B
)

```

C1 is your selected target name.

Replace `targets` with your table name.

Verify that switching the target name updates the margin value correctly.

* * *

### 4. Add a Field Swapper

- In your dashboard or chart, add a **Field Swapper** control.
- Include **Target A** , **Target B** , and **Target C** in the swapper options.
- Test by switching between targets — your **Target Margin** column should update automatically.

* * *

### 5. Add the Reference Line to a Chart

- Open your margin chart.
- Drag **Target Margin** to the **Left Axis**.
- Change the chart type for this field to a **line**.
- Style it to match your dashboard’s theme.

> When you switch targets in the Field Swapper, the reference line will update in real time.

* * *

### 6. Use at the Dashboard Level

The Field Swapper control works across all charts on a dashboard. This means you can change your target once and see every related chart update instantly.

* * *

## Final Result

You now have a **dynamic reference line** that updates based on your chosen target — no manual chart editing required.
