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

# How much revenue comes from a specific category?

> Filtered metric that isolates revenue for a specific product category

## When would you use this?

* You need a governed metric that captures revenue for one specific
  product category, so analysts don't each write their own filter.
* You are building a dashboard and want category-specific revenue
  baked into the metric layer rather than applied as a BI filter.
* You want to track how a single category's revenue changes over
  time, by location, or by channel.

## What this recipe builds

A filtered metric that isolates revenue for a single category. The
filter is baked into the metric definition using
SQL `FILTER (WHERE ...)`. BI users get a pre-governed metric they
can slice freely without needing to know the underlying filter
condition.

The example below uses **Beverage**, **Dessert**, and **Snack**
from a food-truck menu dataset, but the same pattern works for any
category you want to track.

<Tip>
  This recipe uses the [filtered metrics](/docs/calculations/metrics#filtered-metrics) concept.
  See the documentation for the full technical reference.
</Tip>

## Steps

<Steps>
  <Step title="Revenue from beverages">
    Revenue from beverage items only. The filter is part of the
    metric - users never need to add it manually.

    <Tabs>
      <Tab title="SQL">
        ```sql theme={null}
        order_detail.revenue FILTER (WHERE menu.item_category = 'Beverage')
        ```
      </Tab>

      <Tab title="YAML">
        ```yaml theme={null}
        type: metric
        entity: order_detail
        name: revenue_from_beverages
        display_name: Revenue from Beverages
        sql: |-
          order_detail.revenue FILTER (WHERE menu.item_category = 'Beverage')
        ```
      </Tab>
    </Tabs>
  </Step>

  <Step title="Revenue from desserts">
    The same pattern applied to a second category. Repeat for as
    many categories as you need.

    <Tabs>
      <Tab title="SQL">
        ```sql theme={null}
        order_detail.revenue FILTER (WHERE menu.item_category = 'Dessert')
        ```
      </Tab>

      <Tab title="YAML">
        ```yaml theme={null}
        type: metric
        entity: order_detail
        name: revenue_from_desserts
        display_name: Revenue from Desserts
        sql: |-
          order_detail.revenue FILTER (WHERE menu.item_category = 'Dessert')
        ```
      </Tab>
    </Tabs>
  </Step>

  <Step title="Revenue from snacks">
    <Tabs>
      <Tab title="SQL">
        ```sql theme={null}
        order_detail.revenue FILTER (WHERE menu.item_category = 'Snack')
        ```
      </Tab>

      <Tab title="YAML">
        ```yaml theme={null}
        type: metric
        entity: order_detail
        name: revenue_from_snacks
        display_name: Revenue from Snacks
        sql: |-
          order_detail.revenue FILTER (WHERE menu.item_category = 'Snack')
        ```
      </Tab>
    </Tabs>
  </Step>
</Steps>

## Next step

To compute this category's share of total revenue, see
[Category revenue share](/docs/recipes/category-revenue-share).

## Related reading

* [Filters](/docs/calculations/filters) -
  reference on `FILTER (WHERE ...)`
* [Metrics](/docs/calculations/metrics) -
  the metric primitive used in each step
