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.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?”- SQL
- YAML
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?” Thegroup 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.
- SQL
- YAML
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% |
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?”
Related reading
- Revenue for a specific category - prerequisite recipe
- Filters -
reference on
FILTER (WHERE ...) - Ratio metrics - using filtered metrics inside ratio expressions
- Fixed empty grouping -
locking the denominator with
group by ()