# Comparing metrics over arbitrary periods

**URL:** https://community.omni.co/t/comparing-metrics-over-arbitrary-periods/280
**Category:** Patterns
**Tags:** modeling
**Created:** [March 22, 2025, 1:49am UTC](https://community.omni.co/t/comparing-metrics-over-arbitrary-periods/280 "2025-03-22T01:49:05Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![kylee](https://avatars.discourse-cdn.com/v4/letter/k/ea5d25/32.png) [@kylee](https://community.omni.co/u/kylee)
#### Post date: [March 22, 2025, 1:49am UTC](https://community.omni.co/t/comparing-metrics-over-arbitrary-periods/280/1 "2025-03-22T01:49:05Z")

</div>

Omni’s native Period-over-Period comparison is a powerful way to analyze trends between related time frames, such as comparing performance across weeks, months, or years. But what if you need to compare two periods that don’t have a logical sequential relationship? For example, an eCommerce or retail company might want to compare sales performance during Black Friday week versus Memorial Day week.

To enable these kinds of comparisons, we can leverage [filter-only fields](https://docs.omni.co/docs/modeling/templated-filters#filter-only-fields), [templated filters](https://docs.omni.co/docs/modeling/templated-filters) and [filtered measures](https://docs.omni.co/docs/modeling/measures#filters).

First, we’ll need to create two filter-only fields that will allow users to select the two periods they want to compare.

```auto
filters:
  current_period:
    type: timestamp

  previous_period:
    type: timestamp

```

Then, using templated filters we pass the selected periods to our date field. \*Note if you have more than one schema in your database connection, views like users will need to be scoped with schema name like “schema\_\_users”.

```auto
  previous_period_flag:
    sql: |
      {{# users.previous_period.filter }} ${users.created_at} {{/users.previous_period.filter }}

  current_period_flag:
    sql: |
      {{# users.current_period.filter }} ${users.created_at} {{/ users.current_period.filter }}

```

Finally, we can create filtered measures that filter on the dimensions we created above.

```auto
  count_previous:
    aggregate_type: count
    filters:
      previous_period_flag:
        is: true

  count_current:
    aggregate_type: count
    filters:
      current_period_flag:
        is: true

```

With this setup, users can seamlessly compare arbitrary timeframes directly from their workbook or dashboard, and the filtered measures will update dynamically to reflect their selections.

 ![Screenshot 2025-03-21 at 6.41.29 PM](https://canada1.discourse-cdn.com/flex004/uploads/omni/original/1X/f1e4152d0a38c1cdd8366090660ab3f630386507.png)

#templatedfilters
