len
Returns the length of a variable.
When the variable is a string, the function returns the number of characters.
When the variable is a list, the function returns the number of values.
Parameters
VARIABLE (string or list)
The variable to find the length of.
Examples
The function returns the number of characters in a string.
ATL in Script | Result | Notes |
---|---|---|
| 5 | There are five characters in the string. |
| 13 | Whitespace characters are counted. |
The function returns the number of values in a list.
ATL in Script | Result |
---|---|
| 0 |
| 3 |
Using len with table data
Assume a "Describe Row in Context" project with this data:
Branch | Manager | Sales | |
---|---|---|---|
Row 1 | New York | Eric Blair | 1,204,851.24 |
Row 2 | Boston | Elizabeth May | 807,284.86 |
Row 3 | Baltimore | Sam Clemens | 756,912.75 |
Row 4 | Pittsburgh | Mary Evans | 1,029,563.48 |
Use a variable or ATL function to get a list of values, then use len
to count the values.
ATL in Script | Result |
---|---|
| New York, Boston, Baltimore and Pittsburgh |
| 4 |
| Eric Blair and 1,204,851.24 |
| 2 |
To count the characters in an individual cell, use the cell and value functions together.
ATL in Script | Result |
---|---|
| Eric Blair |
| 10 |