In a formula-type column, the NB_ELEMENTS function counts the number of items contained in the selected columns, including columns containing multiple values, such as fields of the Linked Table Column type. It returns a number.
- $field_name = field (link, linked table column, number, selection, formula, text...).
- "free text" = free text to add inside quotes.
- do not use quotes for numbers.
Syntax
Parameters
The output format of the result (number, currency, percentage...) is configured in the output field options of the formula editor. See Output format options in the Formula Column article.
Examples
Count the items in one column
I counted the number of items in the Documents received column to find out the total number.
Count the items in several columns
I counted the number of items in the Documents received column plus the number of items in the Subscriptions column, to know the total number of documents contained in my client's file.
Count items linked to another table
Similarly, I can count the number of items linked to another table. I counted the number of invoices in my Invoice column issued to a given client.
To add values (rather than count them), use SUM_ELEMENTS(). For the smallest or largest value, use MIN_NUM_ELEMENTS() or MAX_NUM_ELEMENTS().
Go further
SUM_ELEMENTS
To add up the numeric values of a linked column, instead of counting them.
Or continue with
Formula glossary
All available operators and functions, sorted by category.