Skip to main content
The unique count aggregation type counts only the unique values of a specified event property.

UNIQUE COUNT calculation method

UNIQUE COUNT billable metric

Here is how you can create a unique count aggregation from the UI:
  1. Access the “Billable metrics” section via the side menu;
  2. Create a new billable metric;
  3. Define a name, a code and an optional description;
  4. Select “count unique” as the aggregation type;
  5. Define if this metric is metered or recurring;
  6. Define the property to aggregate;
  7. Apply dimension groups if any; and
  8. Click “Add billable metric”.
This billable metric can be both metered or recurring.

Calculation example

Lago calculates the COUNT_DISTINCT(events.properties.property_name) for the two following events received.
In that case, with this aggregation type, Lago only counts the unique values of the request_id property in the event payloads, resulting in a billable value of 1 unit.

Adding or removing unique values

Events sent to a UNIQUE COUNT billable metric accept an operation_type property to control whether the unique value is added to or removed from the count:
  • add: Adds the unique value. Optional: Lago adds by default if operation_type is omitted.
  • remove: Removes the unique value from the count. Required whenever you want to explicitly remove a unit.