When would you use this?
- A menu designer asks “Which trucks have customers spending the most per visit?” - requires averaging total order spend, not individual line-item prices.
- Finance wants to track average order value over time to measure whether upselling campaigns are working, sliced by city and truck.
- 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.
- You need an AOV metric that works correctly whether a BI user groups by truck, city, day, or customer age group - without duplicating logic for each view.
What this recipe builds
Two metrics demonstrating the fixed-grouping pattern. The inner metric usesGROUP BY (order_header.order_id) to always compute at
order grain - the grain never changes regardless of user context.
The outer metric averages that fixed-grain value, inheriting
whatever dimension the user has chosen. The result: AOV is always
computed correctly at order grain, regardless of how the data is
sliced.
Steps
1
Revenue per order (inner)
Total revenue per order - always at order grain regardless of user
context. The fixed
GROUP BY never changes.Since it is defined as a metric, it responds to user-applied
filters. For example, filtering to a single city computes
revenue per order for that city only.- SQL
- YAML
2
Average Order Value
Mean spend per order visit. Grouped by truck = AOV per truck.
Grouped by city = AOV per city. Always correct because the inner
grain is fixed.
- SQL
- YAML
Example - sliced by country
Each row shows the average order value for that country. The
inner metric computes revenue per order, and the outer
AVG
collapses to the country level. The global AOV ($40.74) is the
average order value across all orders.
Next step
To compute what fraction of orders exceed a threshold using the fixed-grain metric, see High value order share.Related reading
- Fixed grouping -
reference on
GROUP BY (entity.key)