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.
Prerequisite
This recipe builds on the filtered category revenue metric from
Revenue for a specific category.
Complete that recipe first.
When would you use this?
- A stakeholder asks “What percentage of our revenue comes from
beverages?” and you need a ratio they can slice by time,
location, or truck.
- You want a governed share metric so every dashboard shows the
same number without anyone hand-rolling a division formula.
What this recipe builds
A ratio metric that calculates the filtered category share out of
the total revenue. Because both sides are named metrics, a change
to the filter in the underlying metric automatically flows through
to the share.
The example below computes the share of beverages from a
food-truck menu dataset, but the same pattern works for any
category.
Honeydew offers two flavors of share metric depending on how you
want the denominator to behave when users add grouping dimensions.
This recipe uses the filtered metrics concept.
See the documentation for the full technical reference.
Use case 1 - Share within the current grouping
When a user slices this metric by a dimension - for example,
country - the denominator becomes total revenue for that
country. The share answers: “Of this country’s revenue, how
much came from beverages?”
order_detail.revenue_from_beverages / order_detail.revenue
type: metric
entity: order_detail
name: beverage_revenue_share
display_name: Beverage Revenue Share
description: |-
Beverage items as a share of total revenue.
Ratio metric built from revenue_from_beverages / revenue.
datatype: float
format_string: "0.00%"
folder: Revenue Metrics
sql: |-
order_detail.revenue_from_beverages / order_detail.revenue
Example - sliced by country
Each country’s denominator is that country’s own total revenue:
| Country | Beverage revenue | Country total | Beverage share |
|---|
| India | $51.8M | $1,093.4M | 4.7% |
| Germany | $50.1M | $1,030.8M | 4.9% |
| Brazil | $49.8M | $991.3M | 5.0% |
| Australia | $46.8M | $951.0M | 4.9% |
| United States | $49.2M | $947.7M | 5.2% |
Use case 2 - Share of the global total
When a user slices this metric by any dimension, the denominator
stays the same - total revenue across the entire dataset. The
share answers: “Of all our revenue, how much came from beverages
in this slice?”
The group by () clause tells Honeydew to remove all dimensions
from the denominator’s grouping context. Filters still apply,
but grouping dimensions do not change the denominator.
order_detail.revenue_from_beverages / order_detail.revenue group by ()
type: metric
entity: order_detail
name: beverage_out_of_all
description: |-
The denominator is a metric and will be affected by filters,
but not groups.
datatype: number
sql: |-
order_detail.revenue_from_beverages / order_detail.revenue group by ()
Example - sliced by country
Every country’s denominator is the grand total ($10.1B), so the
values represent each country’s contribution to the overall
beverage revenue:
| Country | Beverage revenue | Grand total | Beverage share |
|---|
| India | $51.8M | $10.1B | 0.51% |
| Germany | $50.1M | $10.1B | 0.50% |
| Brazil | $49.8M | $10.1B | 0.49% |
| Australia | $46.8M | $10.1B | 0.46% |
| United States | $49.2M | $10.1B | 0.49% |
The shares across all countries sum to ~5.0% - the global
beverage share. Each row tells you how much of the entire
company’s revenue that country’s beverages represent.
How the two behave differently
Same data, side by side:
| Country | Beverage revenue | Use case 1 (per-country) | Use case 2 (global) |
|---|
| India | $51.8M | 4.7% | 0.51% |
| Germany | $50.1M | 4.9% | 0.50% |
| Brazil | $49.8M | 5.0% | 0.49% |
- Use case 1 - each country’s denominator is its own total.
Answers “what share of this country’s revenue is beverages?”
- Use case 2 - every row divides by the grand total.
Answers “what share of all revenue is this country’s beverages?”