FLATTEN
Tom Azernour avatar
Written by Tom Azernour
Updated over a week ago

Type: Function

Function: FLATTEN

Syntax: FLATTEN(array_field)

Description: Flatten an array field (e.g. labels) to produce one parent record per value in the array. This operator is useful to turn arrays into single values. Aggregation logic can then be applied on those individual values (e.g. COUNT per individual label).

This operator can only be used in dimension formulas, it cannot be used in metric formulas.

Sample usage:

  • FLATTEN(label_names) will produce one parent record per label in the label_names array, with each record having a single label.

  • FLATTEN(assignee_usernames) will produce one parent record per user in the assignee_usernames array, with each record having a single assignee.

  • Using FLATTEN(label_names) as dimension and COUNT() as metric will produce a reporting counting the number of time each label has been used across all records.

  • Using FLATTEN(label_names) as dimension 1, FLATTEN(assignee_usernames) as dimension 2 and COUNT() as metric will produce a reporting counting the number of label+assignee pairs.

Did this answer your question?