# DbT Semantic Layer: Average Monthly Value

**URL:** <https://discourse.getdbt.com/t/dbt-semantic-layer-average-monthly-value/15505>\
**Category:** Help\
**Tags:** dbt-cloud, semantic-layer\
**Created:** [September 18, 2024, 7:58pm UTC](https://discourse.getdbt.com/t/dbt-semantic-layer-average-monthly-value/15505 "2024-09-18T19:58:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![gbounce](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/gbounce/32/4578_2.png) [@gbounce](https://discourse.getdbt.com/u/gbounce)\
**Post date:** [September 18, 2024, 7:58pm UTC](https://discourse.getdbt.com/t/dbt-semantic-layer-average-monthly-value/15505/1 "2024-09-18T19:58:11Z")

</div>

Currently trying to create a metric in DbT which corresponds to the average monthly value for stores.

With this in mind, I’m creating a derived metric which picks up the base measures and creates the corresponding ratio:

```auto
metrics:
  - name : average_store_monthly_revenue
    label: Average Store Monthly Revenue
    type: derived
    type_params:
      expr: revenue/stores
      metrics:
        - name: revenue
        - name: stores

```

The question is, how to aggregate this at the monthly level? Meaning, so we can actually get the monthly average?

I have tried setting the `time_granularity` parameter but unfortunately, it is only available at the Dimension level.

```auto
metrics:
  - name : average_store_monthly_revenue
    label: Average Store Monthly Revenue
    type: derived
    type_params:
      time_granularity: month
      expr: revenue/stores
      metrics:
        - name: revenue
        - name: stores

```

There is, AFAIK, no option for grouping the data at the monthly level directly on metrics. How would I go about doing this?

How about if we want to expand this metric to consider the Store’s last 6 months of revenue?
