Skip to main content

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-grain order_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:
This recipe uses the ratio metrics concept. See the documentation for the full technical reference.

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.
COUNT(DISTINCT order_header.order_id)
FILTER (WHERE order_detail.order_total_revenue > 50)
/ NULLIF(COUNT(DISTINCT order_header.order_id), 0)

Example - sliced by country

Seoul 2022, top trucks by AOV:
TruckAOVHigh-value order share
260$60.4656.1%
269$58.3850.4%
267$50.6342.9%
257$44.9336.6%
266$44.9037.7%
Trucks 260 and 269 have more than half their orders above $50, making them candidates for premium menu expansion.

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.
1

75th percentile of order revenue

The global 75th percentile, computed with 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.
PERCENTILE_CONT(0.75) WITHIN GROUP
(ORDER BY order_detail.order_total_revenue) group by ()
The current global value is $57.00.
2

Top quartile order share

Orders above the 75th percentile as a share of all orders. The FILTER clause references p75_order_revenue - the percentile metric from the previous step - so the threshold adapts as the data distribution changes.
COUNT(DISTINCT order_header.order_id)
FILTER (WHERE order_detail.order_total_revenue
  > order_detail.p75_order_revenue)
/ NULLIF(COUNT(DISTINCT order_header.order_id), 0)

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

AspectFixed threshold ($50)Percentile (p75)
Cutoff valueAlways $50Currently $57, adapts over time
Share when AOV risesIncreases - more orders cross $50Stays near 25% by definition
Best forBusiness rules, promotion tiersDistribution analysis, outlier detection

Key design notes

ConcernGuidance
Threshold on a fixed-grain metricBoth 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 percentileThe 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 structureBoth metrics divide filtered count by total count. NULLIF prevents division by zero when a slice has no orders.