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 fixed-grainorder_total_revenue metric
from Average order value. Complete that
recipe first.
When would you use this?
- Operations needs to identify premium trucks - those where more than half of orders exceed $50 - to decide which locations to prioritize for higher-end menu items.
- A product manager asks “What share of orders are high-value?” and you need a metric that works across any grouping dimension.
- You want a threshold that adapts to the data distribution rather than a hard-coded dollar amount.
What this recipe builds
A ratio metric that counts orders above a threshold and divides by total orders. The threshold is evaluated at order grain using the fixed-grain inner metric (order_total_revenue), then the
share is computed at user context.
The recipe shows two approaches to defining the threshold:
Use case 1 - Fixed dollar threshold
A hard-coded threshold, that answers: “What percentage of orders exceed 50 dollars” Use this when the business has a specific dollar cutoff that defines “high value” - for example, a promotion tier or a pricing benchmark.- SQL
- YAML
Example - sliced by country
Seoul 2022, top trucks by AOV:| Truck | AOV | High-value order share |
|---|---|---|
| 260 | $60.46 | 56.1% |
| 269 | $58.38 | 50.4% |
| 267 | $50.63 | 42.9% |
| 257 | $44.93 | 36.6% |
| 266 | $44.90 | 37.7% |
Use case 2 - Percentile-based threshold
A data-driven threshold that adapts to the distribution. Instead of a fixed dollar amount, the cutoff is the 75th percentile of order revenue. The share answers: “What percentage of orders fall in the top quartile?” Use this when there is no natural dollar cutoff, or when you want the definition of “high value” to move with the data over time.75th percentile of order revenue
The global 75th percentile, computed with The current global value is $57.00.
group by () so it
stays the same regardless of user grouping. Filters still
apply - filtering to a single country gives that country’s
75th percentile.- SQL
- YAML
Example
The global top quartile share is approximately 24.8% - close to the expected 25% for a 75th-percentile cutoff. The small deviation comes from orders that land exactly on the percentile boundary.How the two behave differently
| Aspect | Fixed threshold ($50) | Percentile (p75) |
|---|---|---|
| Cutoff value | Always $50 | Currently $57, adapts over time |
| Share when AOV rises | Increases - more orders cross $50 | Stays near 25% by definition |
| Best for | Business rules, promotion tiers | Distribution analysis, outlier detection |
Key design notes
| Concern | Guidance |
|---|---|
| Threshold on a fixed-grain metric | Both use cases reference order_total_revenue, which uses a fixed GROUP BY (order_header.order_id). Without fixed grouping, the threshold would apply to line-item prices instead. |
group by () on the percentile | The percentile metric uses group by () so it computes the global percentile. Without it, the percentile would shift per slice, defeating the purpose of a stable cutoff. |
| Ratio structure | Both metrics divide filtered count by total count. NULLIF prevents division by zero when a slice has no orders. |
Related reading
- Average order value - prerequisite recipe
- Filters -
reference on
FILTER (WHERE ...) - Ratio metrics - using filtered metrics inside ratio expressions
- Fixed empty grouping -
locking the percentile with
group by ()