Browse docs
On this page

mvexpand command

Split a field holding several values into one row per value, such as the list a values() aggregation returns.

All ObiQL commands

Turns a field that holds several values into one row per value. Every other column is copied onto each new row.

The usual partner is a values() aggregation, which lists a group's distinct values in one column. Expanding that column gives each value a row of its own, which you can then filter, sort or count.

Over events, the field's text is split on a separator, a comma unless you name another one. Spaces around each value are trimmed and empty pieces are skipped.

Syntax

ObiQL
| mvexpand [limit=<count>] [delim="<separator>"] <field>

Square brackets mark an optional part, and angle brackets a value you supply.

Arguments

ArgumentRequiredDescription
limit=<count>OptionalExpand at most this many values from each row. Defaults to every value.
delim="<separator>"OptionalThe text between values in a field that is not a values() column. Defaults to a comma. A values() column is always expanded value by value, so a value that contains a comma stays whole.
<field>RequiredThe field or column to expand. One per stage. Add a second mvexpand to expand another field.

Usage

  • A row with no value in the field is kept once, with the field empty.
  • Expanding events before a stats counts one row per value. stats count() after mvexpand counts values, not events.
  • Two mvexpand stages over different fields give every combination of their values.
  • mvexpand cannot follow dedup. Move it in front of the dedup.
  • A column added by lookup cannot be expanded, because lookup runs after the search.

Examples

1. One row for each month a service was billed

ObiQL
service=aws-billing | stats values(cost_month) AS month by app | mvexpand month

values() lists the months for each app in one cell, and mvexpand gives each app and month its own row.

2. Count events by each of their tags

ObiQL
| mvexpand tags | stats count() by tags

An event tagged "checkout, mobile" is counted once under each tag.

3. Split a semicolon separated list

ObiQL
| mvexpand delim=";" recipients | fields timestamp, recipients

One row per recipient of each event.

4. Only the first three values

ObiQL
| stats values(host) AS host by service | mvexpand limit=3 host

At most three rows for each service, taking the hosts in sorted order.