Skip to content
This repository has been archived by the owner on Oct 7, 2024. It is now read-only.
Kirill Chernyshov edited this page Mar 13, 2019 · 1 revision

The IFS Function

Function Group: Logical

IFS returns the value that corresponds to the first logical expression which evaluates to TRUE.

Syntax

IFS(cond1, expr1, ... , condN, exprN)

  • condN is a condition that evaluates to truthy of falsy value.
  • exprN is an expression that is evaluated only when corresponding condition returns truthy value. Result is returned as a result of IFS expression.

Notes:

  • IFS expecting even number of arguments.

Uses

With given context:

{
    "users": [
        {
            "name": "Hans",
            "surname": "Petrov"
        },
        {
            "name": "Ivan"
        }
    ]
}

Expression like that:

MAP(IFS(_.surname <> NULL, _.surname, _.surname = NULL, 'Unknown surname'), users)

will return a collection ["Petrov", "Unknown surname"].

In this example we are using MAP function to walk other a list of users fetched from the context and apply IFS to fetch surname attribute from each of them. In case when surname is not defined - return just placeholder.

Clone this wiki locally