Skip to main content

Celonis Product Documentation

IF
Description

IF evaluates a list of static conditions and replaces itself with the query for the first static condition that is true.

Syntax
 IF static_condition THEN expression [ ELSE IF condition THEN calculation ]* [ ELSE calculation ] END

In contrast to STATIC CASE WHEN, an IF query does not require an ELSE. Not specifying an ELSE in an IF results in an empty PQL query if none of the static conditions are met.

NULL handling

If a static condition evaluates to NULL, it is treated as if it was false.

Examples

[1]

In this example, we use IF to apply a filter statement only if the selected_country KPI is 'DE'.

Query

KPI "selected_country"

         {p1}
        

If

         IF KPI ( "selected_country" , 'DE' ) = 'DE' THEN FILTER "Orders"."Country" IN ( KPI ( "selected_country" , 'DE' ) ) ; END;
        

Column1

         "Orders"."Country"
        

Column2

         SUM ( "Orders"."Amount" )
        

Input

Output

Orders

Country : string

Amount : int

'DE'

10

'US'

15

'US'

5

'DE'

10

'DE'

5

Result

Column1 : string

Column2 : int

'DE'

25

See also: