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

Type: Function

Function: ARRAY_FIND

Syntax: ARRAY_FIND(list, "value1","value2","value3")

Description: Returns the first value in a given list that matches the chosen list of search terms. This function is useful to reduce a list of keywords to a single keyword based on an order of precedence.

Example use case:
Your team uses three different labels on pull requests: bug, enhancement, and security. Each pull request can have one or multiple labels attached to them but in your report, you want to surface only the most important label. You decide that security is more important than bug which itself is more important than enhancement (this is your order of precedence).

In your insight, you can create a dimension using the following custom formula to cover this type of grouping: ARRAY_FIND(label_names, "security", "bug", “enhancement”)

Sample usage:

  • ARRAY_FIND(label_names, "bug-minor", "bug-critical") will first attempt to find and return “bug-minor” from the field label_names, then will attempt to find and return “bug-critical” and eventually will return null if none of these values are contained in the field

  • ARRAY_FIND(["bug","enhancement", "security "], "security ", "bug", "enhancement") returns "security "

  • ARRAY_FIND(["bug","enhancement"], "security ", "bug", "enhancement") returns "bug"

Did this answer your question?