Skip to main content

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

[[isNotEmpty("")]]

false

The string is empty.

[[isNotEmpty("New York")]]

true

The string includes a text entry.

Testing lists with isNotEmpty

ATL in Script

Result

Notes

[[isNotEmpty(makeList())]]

false

The list is empty.

[[isNotEmpty(makeList(1,2,3))]]

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

[[isNotEmpty(WholeJSON['results'][0]['score'])]]

true

The object contains a value.

[[isNotEmpty(WholeJSON['results'][1]['score'])]]

false

The object contains an empty string.

[[isNotEmpty(WholeJSON['results'][2]['score'])]]

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

[[isNotEmpty(Score)]]

true

The Row 1 cell contains a value.

ATL in Script

Result (Row 2)

Notes

[[isNotEmpty(Score)]]

false

The Row 2 cell is empty.

Note

In "Describe the Table" projects, use isNotEmpty with cell and value — e.g. use [[isNotEmpty(value(cell('Mary',Score)))]], not [[isNotEmpty(cell('Mary', Score))]].

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.