Skip to main content
Skip to main content
Edit this page

uniqArrayIf

Description

The Array and If combinators can be applied to the uniq function to count the number of unique values in arrays for rows where the condition is true, using the uniqArrayIf aggregate combinator function.

note

-If and -Array can be combined. However, Array must come first, then If.

This is useful when you want to count unique elements in an array based on specific conditions without having to use arrayJoin.

Example Usage

Count unique products viewed by segment type and engagement level

In this example, we'll use a table with user shopping session data to count the number of unique products viewed by users of a specific user segment and with an engagement metric of time spent in the session.

See also