Skip to main content
Some aggregations don’t fit a simple GROUP BY. For example, you may want to show each customer’s lifetime spend on a row-level breakout by product category, or compute each region’s percentage of a grand total. Omni gives you four ways to handle these: an LOD field, a SQL window function, a CTE or derived table, or a spreadsheet. In this guide, you’ll learn about each of these methods, how they compare to each other, and when to choose each one.

Before you start

If you’re new to LOD fields, read Level of detail fields first — this guide assumes basic familiarity with the field type.

Available methods

The right choice usually comes down to whether the calculation needs to be reusable, where you’re comfortable writing logic, and how much data is involved. Use the table below as a starting point; the side-by-side comparison goes deeper on the trade-offs.

Comparing methods

This table compares the four methods across the traits that usually drive the choice. Use it when you want to compare a specific dimension across all four options.
For the best performance on massive datasets, consider using a derived table which can be materialized in your warehouse.

Common scenarios

The three scenarios below cover the patterns that come up most often: bucketing customers by lifetime spend, building acquisition cohorts, and computing percent of total. Each is solved with all four methods side by side, so you can take a pattern you already know in one tool and find its equivalent in another.

Customer lifetime spend

In this scenario, you want “total spend per customer” as a dimension you can use to bucket customers ($0–100, $100–500, and so on), even when viewing orders by product category.
The fields in the workbook’s LOD editor would look like the following:
  • Field to aggregate - Sale price
  • Aggregation - Sum
  • Level of Detail Grouping - Fixed
  • Fixed dimension(s) - User ID

First-touch cohort date

In this scenario, you want each user’s first order date so you can analyze performance by acquisition cohort.
The fields in the workbook’s LOD editor would look like the following:
  • Field to aggregate - Order date
  • Aggregation - Min
  • Level of Detail Grouping - Fixed
  • Fixed dimension(s) - User ID
For a full walkthrough using this approach, see Build cohort analysis using level of detail.

Percent of total

In this scenario, you’re viewing sales by region and want to know what percentage of the company’s total sales each region represents.
The fields in the workbook’s LOD editor would look like the following:
  • Field to aggregate - Sales
  • Aggregation - Sum
  • Level of Detail Grouping - Exclude
  • Fixed dimension(s) - Region
This returns the grand total on every row, so you can divide each row’s sales by it to get percent of total.

Next steps