1. Docs
  2. Formulas
  3. Functions

COUNTIF

Returns the count of all elements in an array that are equal to the comparison argument.

Categories: Arrays, Lambdas

Syntax

COUNTIF(array, comparison)

Examples

Example 1

Input

1
{
2
"my_action": {
3
"message": [
4
"north",
5
"south",
6
"east",
7
"west",
8
"north"
9
]
10
}
11
}

Formula

COUNTIF(my_action.message, "north")

Output

2

Example 2: Comparison can also be a lambda.

Input

1
{
2
"my_action": {
3
"message": [
4
{
5
"count": 6
6
},
7
{
8
"count": 2
9
},
10
{
11
"count": 1
12
},
13
{
14
"count": 3
15
}
16
]
17
}
18
}

Formula

COUNTIF(my_action.message, LAMBDA(item, item.count > 1))

Output

3

Sample actions

Event Transform
COUNTIF
Event Transform
My Action

Select an action to inspect

You can also click "Copy actions" and paste them in your Tines story to see how they work.

Was this helpful?