Skip to main content

isEmpty

Tests if a string, list, table cell, or JSON object is empty.

The function returns a Boolean true (empty) or false (not empty).

The function returns a Boolean true for null values.

This 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 isEmpty

ATL in Script

Result

Notes

[[isEmpty("")]]

true

The string is empty.

[[isEmpty("New York")]]

false

The string includes a text entry.

Testing lists with isEmpty

ATL in Script

Result

Notes

[[isEmpty(makelist())]]

true

The list is empty.

[[isEmpty(makelist(1,2,3))]]

false

The list contains numbers.

Testing JSON objects with isEmpty

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

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

false

The object contains a value.

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

true

The object contains an empty string.

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

true

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 isEmpty

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

[[isEmpty(Score)]]

false

The Row 1 cell contains a value.

ATL in Script

Result (Row 2)

Notes

[[isEmpty(Score)]]

true

The Row 2 cell is empty.

Note

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

Using isEmpty 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(isEmpty(Score)){[[FocusRowName]]'s score is unknown.}else{[[FocusRowName]] scored [[Score]].}]]

The conditional statement ensures appropriate narrative text is returned.

Row 1 Result

Row 2 Result

Peter scored 67.

Mary's score is unknown.