COUNTIF
Use COUNTIF to count the number of items in an array that meet a given criteria.
Use
COUNTIF( array, criteria )
Counts the number of items in the array that meet the given criteria.
| Parameter | Required | Description |
|---|---|---|
| array | Yes | an array of any type |
| criteria | Yes | a number, expression, or text value that determines which items will be counted |
| Returns | Number |
The format of the criteria depends on the type of the array parameter, as follows:
| Array type | Criteria |
|---|---|
| Text | The criteria is a Text value, which can be a literal, a field, or a formula that returns a Text value. |
| Number | The criteria can be either a number or an expression, as follows: Critera as a number The criteria is a Number value, which can be a literal, a field, or a formula that returns a Number value..Critera as an expression The expression needs to include both an operator and an operand. Supported operators are; = (Equals), != (Not equals), > (Greater than), < (Less than), >= (Greater than or equals) and < (Less than or equals).An operand is is a Number value, which can be a literal, a field, or a formula that returns a Number value.The text join operator & can also be used to combine elements to make up a criteria, such as "<= " & @inp.Amount |
| Logical | The criteria is a Logical value, which can be a literal, a field, or a formula that returns a Logical value. |
| Choice | The criteria is a Text value, which can be a literal, a field, or a formula that returns a Text value. |
| Date | The criteria can be either a date or an expression, as follows: Critera as a date The criteria is a Date value, which can be a literal, a field, or a formula that returns a Date value.Critera as an expression The expression needs to include both an operator and an operand. Supported operators are; = (Equals), != (Not equals), > (Greater than), < (Less than), >= (Greater than or equals) and < (Less than or equals).An operand is is a Date value, which can be a literal, a field, or a formula that returns a Date value.The text join operator & can also be used to combine elements to make up a criteria, such as "<= " & @inp.Anniversary |
| Time | The criteria can be either a time or an expression, as follows: Critera as a time The criteria is a Time value, which can be a literal, a field, or a formula that returns a Time value.Critera as an expression The expression needs to include both an operator and an operand. Supported operators are; = (Equals), != (Not equals), > (Greater than), < (Less than), >= (Greater than or equals) and < (Less than or equals).An operand is is a Time value, which can be a literal, a field, or a formula that returns a Time value.The text join operator & can also be used to combine elements to make up a criteria, such as "<= " & @inp.ClosingTime |
| Date/Time | The criteria can be either a date/time or an expression, as follows: Critera as a date/time The criteria is a Date/Time value, which can be a literal, a field, or a formula that returns a Date/Time value.Critera as an expression The expression needs to include both an operator and an operand. Supported operators are; = (Equals), != (Not equals), > (Greater than), < (Less than), >= (Greater than or equals) and < (Less than or equals).An operand is is a Date/Time value, which can be a literal, a field, or a formula that returns a Date/Time value.The text join operator & can also be used to combine elements to make up a criteria, such as "<= " & @inp.Appointment |
Examples
Path Condition (Routing Based on High-Value Items)
You can use COUNTIF on a Branch step to determine the flow of an approval based on the contents of an array captured in a previous step.
- Scenario: A claim contains a list of individual expense amounts in a Number Array called
@SubmitClaim.out.Amounts. If even one item in that list exceeds a company threshold (e.g., $50), the request must follow a "Manager Review" path. - Formula:
COUNTIF(@SubmitClaim.out.Amounts, "> 50") > 0 - Logic:
@SubmitClaim.out.Amounts: The array of numbers being checked."> 50": The criteria expression. The function looks for any number greater than 50.- Outcome: If the function finds one or more items meeting the criteria, it returns a number greater than 0, making the path condition TRUE.
Validation Logic (Ensuring Consistent Responses)
In an Output Validation formula, you can use COUNTIF alongside COUNTALL to ensure that every single item in a user-submitted list matches a required value.
- Scenario: A user is filling out a safety checklist (a Logical Array). To submit the form, every item in the checklist must be marked as TRUE.
- Formula:
COUNTIF(this, TRUE) = COUNTALL(this) - Logic:
this: Refers to the current Logical Array being validated.COUNTIF(this, TRUE): Counts only the items in the array that are set to TRUE.COUNTALL(this): Returns the total number of items in the array, including blanks.- Outcome: The formula only returns TRUE (valid) if the number of "TRUE" responses matches the total number of items in the list, ensuring no "FALSE" or "BLANK" entries remain.