isNotEmpty
Tests if a string, list, table cell or JSON object is not empty.
The function returns a Boolean true (not empty) or false (empty).
The function returns a Boolean false for null values.
The function is typically used in conditional statements — see here for an example.
Parameters
INPUT (string, list, cell, or JSON object)
The element to test. Can be a string, list, cell, or JSON object.
Examples
Testing strings with isNotEmpty
ATL in Script | Result | Notes |
---|---|---|
| false | The string is empty. |
| true | The string includes a text entry. |
Testing lists with isNotEmpty
ATL in Script | Result | Notes |
---|---|---|
| false | The list is empty. |
| true | The list contains numbers. |
Testing JSON objects with isNotEmpty
Assume a "Describe a JSON Object" project with this data:
{ "results": [ { "name": "Peter", "score": 67 }, { "name": "Paul", "score": "" }, { "name": "Mary", "score": null } ] }
The "results" array contains three JSON objects. Each object contains two key–value pairs.
ATL in Script | Result | Notes |
---|---|---|
| true | The object contains a value. |
| false | The object contains an empty string. |
| false | The object contains a null value. |
Note
With JSON data, a null value is indicated by a null literal — see the example data above.
Testing table cells with isNotEmpty
Assume a "Describe Row in Context" project with this data:
Name | Score | |
---|---|---|
Row 1 | Peter | 67 |
Row 2 | Mary |
These examples test whether there is a value in the Score column for the focus row:
ATL in Script | Result (Row 1) | Notes |
---|---|---|
| true | The Row 1 cell contains a value. |
ATL in Script | Result (Row 2) | Notes |
---|---|---|
| false | The Row 2 cell is empty. |
Using isNotEmpty in a conditional statement
Again, assume a "Describe Row in Context" project with this data:
Name | Score | |
---|---|---|
Row 1 | Peter | 67 |
Row 2 | Mary |
You might write a conditional statement to cover the possibility of a missing Score value. For example:
[[if(isNotEmpty(Score)){[[FocusRowName]] scored [[Score]].}else{[[FocusRowName]]'s score is unknown.}]]
The conditional statement ensures appropriate narrative text is returned.
Row 1 Result | Row 2 Result |
---|---|
Peter scored 67. | Mary's score is unknown. |