Skip to main content

Logical Functions

Legacy Feature

Starting from April 19, 2024, Business Calculation and Holistics Expression are no longer supported for new user signups, and are only be available for legacy use cases.

Holistics Expression is now replaced by AQL Expression with enhanced functionality.

Logical functions return value based on some logical conditions.

case when

case(when: condition_expression, then: value_expression, else: value_expression)            

Description

The CASE statement goes through conditions and returns a value when the first condition is met (like an IF-THEN-ELSE statement).

Return type

Vary

Example

Given a Holistics expression as below:

case(
when: users.gender == 'm', then: 'male',
when: users.gender == 'f', then: 'female',
else: 'others'
)

The SQL output would be:

Case 
When users.gender = 'm' then 'male'
When users.gender = 'f' then 'female'
Else 'others'
End

And the result would be:

gendercase
mmale
ffemale
mmale

and()

and(condition_expression, ...)          

Description

Logical AND compares between two Booleans as expression and returns true when both expressions are true.

Return type

Boolean

Example

Given a Holistics expression as below:

and(
products.id >= 2,
products.id <= 8
)

The SQL output would be:

(
(products.id >= 2.0) AND (products.id <= 8.0)
)

And the result would be:

idand
1false
2true
8true
9false

or()

or(condition_expression, ...)       

Description

Logical OR compares two Booleans as expression and returns true when one of the expressions is true.

Return type

Boolean

Example

Given a Holistics expression as below:

or(condition_expression, ...)

The SQL output would be:

or(
products.id <= 2,
products.id >= 8
)

And the result would be:

idor
1true
4false
7false
9true

not()

not(field_expression)       

Description

Logical NOT takes a single Boolean as an argument and invert it.

Return type

Boolean

Example

Given a Holistics expression as below:

not(is(products.id, null))

The SQL output would be:

NOT (products.id IS NULL)

And the result would be:

idnot
1true
false
3true
4true

is()

is(field_expression)        

Description

Logical IS evaluates the given statement and return either true or false.

Return type

Boolean

Example

Given a Holistics expression as below:

is(products.id, null))

The SQL output would be:

(products.id IS NULL)

And the result would be:

idnot
1false
true
3false
4false

in()

in(field_expression, value_expression, value...)    

Description

in operator takes a field expression and a list of values. Return true if that list of values contains the value of that field expression.

Return type

Boolean

Example

Given a Holistics expression as below:

in(users.name, 'bob', 'alice', 'jack)

The SQL output would be:

user.name in ('bob', 'alice', 'jack)

And the result would be:

namein
bobtrue
alicetrue
peterfalse

Let us know what you think about this document :)