count_if

statistics

Count of values where mask is true

Syntax

count_if(values, mask)

Parameters

values (array)

The values to count

mask (boolean expression)

Condition to filter values

Returns

number

The count of values where mask is true

Examples

Count high-value transactions
Input:
count_if(.amount, .amount > 1000)
Output:
23
Count completed orders
Input:
count_if(.status, .status == "completed")
Output:
142

The count_if() function counts the number of values where a condition (mask) is true, enabling conditional counting.

Usage

Use count_if() for counting items that meet specific criteria, filtering data inline without separate filter operations.

Related Functions