A usage metric is a formula that aggregates a set of events into a single number representing total usage. To create a usage metric in the Sequence dashboard, click “Add new” and select “Usage metric”:

Add Usage metric

Give the metric a name and the type of usage events you want to aggregate – this should match the eventType in the usage event object. Then select how you want to aggregate the events; Sequence currently supports 3 aggregation types:

Aggregation typeRequires aggregation propertyDescriptionSQL equivalent
COUNTnoTotal number of eventsCOUNT(*)
SUMyesSum of a numeric propertySUM(properties[‘property_name’])
UNIQUEyesCount of unique values of a propertyCOUNT(DISTINCT properties[‘property_name’])

SUM and UNIQUE require you to specify an event property as the argument of the aggregation, enter the name of this property in the “Aggregation property” field.

When the billing engine runs, it calculates all usage metrics for each of your customers over the last billing period. This calculated value is then combined with a price to determine the charge that will appear on the invoice.

Filtering

You can further refine the scope of a usage metric using filters. A filter limits the aggregation input to events that match a specific event property value. For example, if your events have a property called method, you can filter your metric to events where method = card_payment:

Metric filters

If multiple filters are specified, only events matching all filters are included in the metric calculation.

Grouping

Use grouping to customize the layout of a usage-based charge on an invoice by breaking down usage by an event property. For example, grouping by method will let you display the usage for method = card_payment and method = direct_debit on separate lines on the invoice. To learn more about customizing your invoice layout via grouping, reach out to the Sequence team.

Editing metrics

Updating and deleting usage metrics is currently only supported via the API. Making changes to a metric will not retroactively affect invoices already created. To update or correct existing invoices after changing a metric, recalculate a draft invoice, or issue a credit note against an issued invoice.