First
The first value or array of values.
Other
Additional values or arrays of values.
Locale
The locale to use when doing number conversions.
A locale represents a language and possibly a region. If omitted, the configured locale is used.
Use a value such as Locale.EnglishLocale,English to provide a locale (the full list is below). If your chosen locale is not part of the list, use the LOCALE function instead.
All locales may not be available. If a locale is not available, a fallback locale can be used. To provide such fallback locales, use the LOCALE function.
The LOCALE function accepts so-called Unicode Locale Identifiers. Every value in the list below corresponds to such an identifier.
| Formula | Unicode Locale Identifier | Description |
|---|---|---|
| Locale.ArabicLocale,Arabic | ar | Arabic |
| Locale.BulgarianLocale,Bulgarian | bg | Bulgarian |
| Locale.ChineseCnLocale,ChineseCn | zh-CN | Chinese (simplified), as used in mainland China |
| Locale.ChineseTwLocale,ChineseTw | zh-TW | Chinese (traditional), as used in Taiwan |
| Locale.CroatianLocale,Croatian | hr | Croatian |
| Locale.CzechLocale,Czech | cs | Czech |
| Locale.DanishLocale,Danish | da | Danish |
| Locale.DutchLocale,Dutch | nl | Dutch |
| Locale.DutchBeLocale,DutchBe | nl-BE | Dutch, as used in Belgium |
| Locale.EnglishLocale,English | en | English |
| Locale.EnglishAuLocale,EnglishAu | en-AU | English, as used in Australia |
| Locale.EnglishCaLocale,EnglishCa | en-CA | English, as used in Canada |
| Locale.EnglishInLocale,EnglishIn | en-IN | English, as used in India |
| Locale.EnglishNzLocale,EnglishNz | en-NZ | English, as used in New Zealand |
| Locale.EnglishUkLocale,EnglishUk | en-GB | English, as used in the United Kingdom |
| Locale.EnglishUsLocale,EnglishUs | en-US | English, as used in the United States of America |
| Locale.EnglishZaLocale,EnglishZa | en-ZA | English, as used in South Africa |
| Locale.FinnishLocale,Finnish | fi | Finnish |
| Locale.FrenchLocale,French | fr | French |
| Locale.FrenchBeLocale,FrenchBe | fr-BE | French, as used in Belgium |
| Locale.FrenchCaLocale,FrenchCa | fr-CA | French, as used in Canada |
| Locale.FrenchChLocale,FrenchCh | fr-CH | French, as used in Switzerland |
| Locale.GermanLocale,German | de | German |
| Locale.GermanAtLocale,GermanAt | de-AT | German, as used in Austria |
| Locale.GermanChLocale,GermanCh | de-CH | German, as used in Switzerland |
| Locale.GreekLocale,Greek | el | Greek |
| Locale.HebrewLocale,Hebrew | he | Hebrew |
| Locale.HindiLocale,Hindi | hi | Hindi |
| Locale.HungarianLocale,Hungarian | hu | Hungarian |
| Locale.IndonesianLocale,Indonesian | id | Indonesian |
| Locale.ItalianLocale,Italian | it | Italian |
| Locale.ItalianChLocale,ItalianCh | it-CH | Italian, as used in Switzerland |
| Locale.JapaneseLocale,Japanese | ja | Japanese |
| Locale.KoreanLocale,Korean | ko | Korean |
| Locale.NorwegianLocale,Norwegian | nb | Norwegian (bokmål) |
| Locale.PersianLocale,Persian | fa | Persian |
| Locale.PolishLocale,Polish | pl | Polish |
| Locale.PortugueseLocale,Portuguese | pt | Portuguese |
| Locale.PortugueseBrLocale,PortugueseBr | pt-BR | Portuguese, as used in Brazil |
| Locale.RomanianLocale,Romanian | ro | Romanian |
| Locale.RussianLocale,Russian | ru | Russian |
| Locale.SlovakLocale,Slovak | sk | Slovak |
| Locale.SpanishLocale,Spanish | es | Spanish |
| Locale.SpanishArLocale,SpanishAr | es-AR | Spanish, as used in Argentina |
| Locale.SpanishEsLocale,SpanishEs | es-ES | Spanish, as used in Spain |
| Locale.SpanishMxLocale,SpanishMx | es-MX | Spanish, as used in Mexico |
| Locale.SwedishLocale,Swedish | sv | Swedish |
| Locale.ThaiLocale,Thai | th | Thai |
| Locale.TurkishLocale,Turkish | tr | Turkish |
| Locale.UkrainianLocale,Ukrainian | uk | Ukrainian |
| Locale.VietnameseLocale,Vietnamese | vi | Vietnamese |
Returns
The number of parameters which can be interpreted as numbers.
Returns the number of values which can be interpreted as numbers. COUNT (1, 2, BLANK (), "3", "test", TRUE, Color.Red) COUNT (1; 2; BLANK (); "3"; "test"; TRUE; Color,Red) returns 4, because only the 1, 2, "3" and TRUE parameters can be interpreted as numbers.
This function only counts numbers, temporal values, logical values and text values representing numbers (as parsed using TONUMBER). Temporal values are counted, as they can be interpreted as numbers. Blank values, in particular, are ignored. To count the number of elements in an array, use SIZE instead.
COUNT takes the configured locale into account when converting text strings to numbers. If the locale is German, for instance, text strings representing numbers should use a comma (",") as a decimal separator. If the locale is UK English, a decimal point (".") should be used. Thousands separators may not be used.
Count anything
Using a combination of FILTER and SIZE, you can use any criteria you like. Consider this formula:
The formula above returns a version of NumberArray where only elements greater than 4 are included. Use the SIZE function to count the number of elements in the returned array:
The formula above returns the number of elements of NumberArray which are greater than 4.
It's easy to replicate what COUNT does armed with this knowledge, and the fact that TYPE can be used to determine if an array element is a number, a temporal value or a logical value:
The formula above returns the number of array elements which are numbers, temporal values, logical values, or are text strings that can be successfully parsed using TONUMBER and are not blank, which is exactly what COUNT does. TONUMBER returns an error if a text string can't be turned into a number, which ISERROR checks for. The TYPE (Element) = 2 TYPE (Element) = 2 test restricts that check to text strings, as TONUMBER also succeeds when given a color. || is the "logical or" operator, which is equivalent to the OR function in non-array contexts. && is the "logical and" operator, equivalent to the AND function. ! is the "logical negation" operator which turns FALSE into TRUE and TRUE into FALSE.
Counting can also be done with REDUCE. Here's the equivalent REDUCE formula:
Refer to the REDUCE documentation to learn more about how this example works (specifically, this example is similar to the XOR example in that documentation).
Examples
Returns 4, because only the 1, 2, "3" and TRUE parameters count.
Returns 2, as temporal values are counted alongside numbers.
Returns the number of NumberArray elements which can be interpreted as numbers.
Returns the number of elements of NumberArray which are numbers or logical values or are text strings which can be parsed with TONUMBER. Here, NumberArray is filtered using FILTER, TYPE, ISERROR and TONUMBER, leaving only values which can be interpreted as numbers. FILTER accepts an array as its first parameter and a condition as its second parameter, and returns an array consisting only of those elements which satisfy the condition. The condition parameter (where Element is set to the array element to be inspected) returns TRUE only if TYPE indicates that the item is either a number or a logical value, or if TONUMBER does not return an error when applied to it. || is the "logical or" operator, which is equivalent to the OR function in non-array contexts. ! is the "logical negation" operator which turns FALSE into TRUE and TRUE into FALSE.
Returns 4, because only the 1, 2, "3" and TRUE values count. Arrays are supported.
Returns 4, because only the 1, 2, "3" and TRUE values count. Arrays mixed with regular numbers are supported.
Returns 1 if the configured locale is US English (in which case only "1.0" is classified as a number) and 2 if the configured locale is German (in which case only "2,0" and "3,0" are classified as numbers).