See also: numFilter (Number filter), notEmptyFilter (List non-empty values)
The function $count counts the number of given values. Both the individual parameters and parameters that are themselves a list are included in the result.
Tooltip
Syntax: $count(a[,b[,c[,...]]])
$count() accepts an arbitrary number of parameters for which the following applies:
if a parameter is not a list, it is added to the result, regardless of whether it is empty, undefined or null.
if a parameter is a list, each entry of the list is added to the result, regardless of whether it is empty, undefined or null.
Returns the number of specified values. If a value is itself a list, the number of its entries is also added to the result.
Examples: $count(a,b,c) – returns 3$count(a,b,c,$null) – returns 4 (Tip: $notEmptyFilter to filter out empty values).
Syntax
$count(a[,b[,c[,...]]])
Parameter
$count() accepts any number of parameters to which the following applies:
If a parameter is not a list, it is added to the result, regardless of whether it is empty, undefined or null.
If a parameter is a list, then every entry in the list is added to the result, regardless of whether it is empty, undefined or null.
Hint: To exclude undefined or empty values from the result, the function notEmptyFilter (List non-empty values) can be used (analog numFilter (Number filter) for numeric values).
Example: $count(a,$null,,d) returns 4 whereas $count($notEmptyFilter(a,$null,,d) returns 2.
Return value
The number of specified values. If a value is itself a list, the number of its entries is also added to the result.
Example
Syntax | Result | Remarks |
|---|---|---|
$count(a,b,c) | 3 | Each parameter is counted. |
$count(a,b,c,$null) | 4 | Null and empty values are counted anyway. |
$count($numfilter(a,2,3,$null,abc),b,c) | 4 | $numfilter returns the list [2,3] and therefore the result together with the parameters b and c gives a total number of 4. |
$count($notEmptyFilter(a,2,3,$null,abc),b,c) | 6 | $notEmptyFilter returns the list [a,2,3,abc] and therefore the result together with the parameters b and c is 6. |
$count($el(28,true)) | Number of duplicates of the element 28 | Only applicable in forms. |