0% found this document useful (0 votes)
1K views252 pages

Sap Signavio Process Intelligence Signal Reference en

This document provides a guide to the SAP Signavio Analytics Language. It describes the syntax, clauses, expressions, functions and other aspects of the language. The guide contains sections on SELECT statements, subqueries, aggregation, filtering and more. It also includes tutorials and examples of how to use the language to analyze process data.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1K views252 pages

Sap Signavio Process Intelligence Signal Reference en

This document provides a guide to the SAP Signavio Analytics Language. It describes the syntax, clauses, expressions, functions and other aspects of the language. The guide contains sections on SELECT statements, subqueries, aggregation, filtering and more. It also includes tutorials and examples of how to use the language to analyze process data.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 252

PUBLIC

2024-05-23

SAP Signavio Analytics Language Guide


© 2024 SAP SE or an SAP affiliate company. All rights reserved.

THE BEST RUN


Content

1 SAP Signavio Analytics Language. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4


1.1 Syntax. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6
1.2 Aliases. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.3 SELECT Statement and Clauses. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .9
SELECT DISTINCT Clause. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
FROM Clause. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
WHERE Clause. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .16
FILTER Clause. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
FILTER EVENTS Clause. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .19
GROUP BY Clause. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
ORDER BY Clause. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
FILL Clause. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
LIMIT Clause. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
TABLESAMPLE Clause. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
OFFSET Clause. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
FLATTEN Operator. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
UNION ALL Clause. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
1.4 Subqueries. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
General Subqueries. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
Event-Level Subqueries. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
1.5 Expressions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
Arithmetic Expressions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
Comparison Expressions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
Logical Expressions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
Matching Expressions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
LIKE and ILIKE Expressions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
Conditional Expressions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
Expressions for NULL Values. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .79
Literal Expressions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
1.6 Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .83
Aggregate Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
Arithmetic Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
Conditional Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .108
Conversion Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
Date Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122
String Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .140

SAP Signavio Analytics Language Guide


2 PUBLIC Content
Window Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
BUCKET Function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .198
Numeric Rounding Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201
1.7 Keywords. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .203
1.8 Performance. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209

2 Tutorial. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211
2.1 Understand the sample process. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212
2.2 Count cases and cities. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213
2.3 Analyze order amounts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217
2.4 Determine case cycle times. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220
2.5 Investigate events. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223

3 SIGNAL Cookbook. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228


3.1 Cycle Time. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228
Average Cycle Time. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229
Cycle Time Between Events. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230
3.2 Variants. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233
Top N Variants. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233
3.3 Rework and Repeated Events. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236
Cases With More Than N Repeated Events. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236
3.4 Compliance. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
Compliance Rate for a Subset of Cases. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
3.5 Pattern Matching and Deviations. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240
Incomplete Cases. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .241
3.6 Time Series. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242
Filtered Events With Gaps Filled. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .242
Active Cases Within a Period. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246

SAP Signavio Analytics Language Guide


Content PUBLIC 3
1 SAP Signavio Analytics Language

Query language of SAP Signavio Process Intelligence optimized for performing process mining tasks on large
amounts of event data

SAP Signavio Analytics Language, SIGNAL is a specialized query language for process analysis.

The language is based on SQL. Like SQL, you use queries to retrieve data and perform calculations on the data.
However, it is not possible to change or delete process data.

The difference to SQL is the data model. While you usually query data from multiple tables with SQL, SIGNAL
queries the data from only one table, which contains nested events. In addition, SIGNAL provides numerous
custom functions to work more effectively with this data structure.

SIGNAL is optimized for process mining, for example to determine conformance, cycle times, and rework, and
it supports exploration at scale by all kind of SAP Signavio Process Intelligence users.

With SIGNAL, you can only retrieve data from processes to which you have access.

Data model

When mining the data of a process, you retrieve the data of a single table. This table contains the case
attributes and their nested events and event attributes. The following table shows this nested structure.

case_ID Customer ID Status City events

1001 2001 delivered Berlin


Payment Cancellation
event_name end_time method reason

Receive cus- 2020-07-01T


tomer order 09:00:00

Receive pay- 2020-07-02T Bank trans-


ment 10:00:00 fer

Ship goods 2020-07-03T


11:00:00

1002 2002 canceled


Payment Cancellation
event_name end_time method reason

Receive cus- 2020-07-04T


tomer order 13:00:00

Cancel order 2020-07-04T Wrong size


14:00:00

SAP Signavio Analytics Language Guide


4 PUBLIC SAP Signavio Analytics Language
The columns case_id, event_name and end_time are always present. Case attributes like Customer ID ,
Status, and City have the same value throughout the case. Additional event attributes, in this example
Payment method and Cancellation reason can have different values for each event.

There are two ways to iterate over this data:

• per case
Each case is treated as one row. The nested events and event attributes are represented as a nested table.
• per event
Each event is treated as one row. The case ID and case attributes are repeated for each event.

Data types

The data type of a column defines which value the column can hold. All data types can occur on case level as
well as on event level (nested).

SIGNAL supports the following data types:

• Strings
• Numbers stored as double precision floating point
• Timestamps stored with millisecond precision, without time zone information.
• Durations stored with millisecond precision
• Booleans

All of these data types can appear in the source file and in the query result.

Both case and event attributes can be Null, indicating the absence of a value or an unknown value.

Process mining

SIGNAL queries are used in the widgets of an investigation.

When configuring widgets, you have the following options:

• Create you own queries


• Use the default queries in the widgets and customize them if necessary
• Use the predefined queries from the metrics library and customize them if necessary
• Add your own queries to the metrics library for reuse

Read more on the widgets in section Widgets.

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 5
1.1 Syntax

SIGNAL follows a specific syntax that is described throughout this documentation using a special notation.

The syntax of SIGNAL is based on SQL but enhanced with functions to run in-depth process analysis queries.
All queries always follow this basic structure:

SELECT expressions
FROM table/process
WHERE conditions

 Example

Example

This query counts the cases in the declared table for which the condition is true.

Syntax Notation

The following notation is used to describe the syntax of SIGNAL. Note that this notation isn't part of the actual
query:

• Angle brackets indicate a required element. Don't include the angle brackets as part of a query.

SAP Signavio Analytics Language Guide


6 PUBLIC SAP Signavio Analytics Language
Example: ORDER BY <expression>
• Square brackets indicate optional elements. Don't include the square brackets as part of a query.
Example: [ WHERE <condition> ]
• The pipe symbol indicates a choice between two or more options. They're listed within square brackets
(meaning inclusion of a choice is optional) or curly brackets (meaning one of the options must be chosen).
Don't include the pipe or brackets as part of a query.
Example: [ ASC | DESC ]
Example: { AND | OR }
• An ellipsis indicates that the preceding element can be repeated an arbitrary number of times.
Example: GROUP BY columnIndex [, columnIndex ...]

Keywords

SIGNAL keywords are case-insensitive, but are by convention written upper-case to distinguish them from
expressions. Read more on keywords in section SIGNAL keywords [page 203].

Attribute Names

Attribute names are case-insensitive. In the following cases, the attribute name must be enclosed in double
quotes:

• The attribute shares the same name a reserved SIGNAL keyword.


• The attribute doesn't start with a letter or an underscore.
• The attribute name contains characters other than letters, numbers, or underscores.
• If the attribute name is enclosed in double quotes, the entire expression must be enclosed in double
quotes.
Example: "Premium User" -> ""Premium User""
• If the attribute name contains one or more double quotes, these double quotes must be followed by a
double quote.
Example: Width in " (inches) -> "Width in "" (inches)"
• If the attribute name contains one or more single quotes, these single quotes must be followed by a double
quote.
Example: O'Reilly -> "O'"Reilly"

Attribute Values

Attribute values are, where applicable, case-sensitive. Attribute values of type String, Timestamp, and Duration
must always be enclosed in single quotes.

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 7
Semantic Attributes

For SIGNAL, the following pre-defined semantic attributes are always present:

• case_id: Unique identifier of the case


• event_name: Event names of the case ordered by their time
• end_time: End timestamps of the events of a case
• start_time: Start timestamps of the events of a case, can be null if not available in the source data

The syntax rules for semantic attributes are the same as for the other attributes.

1.2 Aliases

Learn about aliases in SIGNAL, the process mining query language of SAP Signavio Process Intelligence.

Aliases are used to give the result set a temporary name to make the column headings in your result set
easier to read. It's common to alias a column when using an aggregate function in a query. Without an alias, a
name will be generated based on the column and operations in the expression. Read more in section SIGNAL
functions [page 83].

An alias is only valid within the scope of the SIGNAL statement.

Syntax:

expression AS alias_name

Parameter Description Required

expression The expression that you want to give a Required


better name.

alias_name The temporary name to assign. Required

Enclose the name in double quotes if it


contains a character that isn't a letter
or digit.

Example:

In this example, we have the following data in a table:

case_id event_name end_time

1001 Receive customer order 2020-07-01T09:00:00

1002 Receive customer order 2020-07-04T13:00:00

1003 Receive customer order 2020-07-05T11:00:00

Enter the following SIGNAL statement:

SELECT COUNT(case_id) AS "No. of cases"

SAP Signavio Analytics Language Guide


8 PUBLIC SAP Signavio Analytics Language
FROM THIS_PROCESS

This query returns the following result set:

No. of cases

1.3 SELECT Statement and Clauses

Use the SELECT statement to select data from a process and return it in a result set.

Syntax

SELECT { <columnExpression> [FILTER (WHERE <condition>)] [, ...] | * }


FROM <tableExpression>
[TABLESAMPLE EXACT( { <probability> PERCENT | <num> ROWS } ) [ REPEATABLE(
<seed> ) ] ]
[FILTER EVENTS WHERE <booleanExpression>]
[WHERE <whereExpression>]
[UNION ALL <selectStatement>]
[GROUP BY <columnIndex> [, <columnIndex> ...] ]
[ORDER BY <columnIndex> [ { ASC | DESC } ] [ NULLS { FIRST | LAST } ] [, ... ] ]
[FILL <fillSpecification> [, <fillSpecification>, ...] ]
[LIMIT <count>]
[OFFSET <start>]

Clause Description

SELECT Specifies columns or values to be included in a result set.

FROM Specifies the table in your process from which you want to retrieve the data. You
can reference the process by using the explicit Process ID, which can be found
on the API tab in the process settings page. Alternatively you can use the alias
THIS_PROCESS to refer to the default view.

TABLESAMPLE Specifies the absolute or percentage table fraction to be considered for the query.

FILTER EVENTS Filters rows at event-level.

WHERE Specifies the condition that must be met for cases to be selected. If this clause
isn't provided, then all records are selected.

UNION ALL Concatenates the result sets of two or more SELECT statements.

GROUP BY Collects data across multiple records and groups the results by one or more
columns. The GROUP BY clause requires an index similar to the ORDER BY
clause. You can use one or multiple indices.

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 9
Clause Description

ORDER BY Sorts the records in the result set. If more than one index is provided, separate
them with a comma.

ASC sorts the result set in ascending order by expression, DESC sorts it in
descending order.

NULLS FIRST sorts the result set with null values first, NULLS LAST with null
values last.

FILL Fills any gaps inside a time series column by inserting new rows into the result
set, each containing missing timestamps.

LIMIT Specifies the number of records in the result set.

OFFSET Specifies the starting point to return rows from a result set.

Column Expressions

The SELECT statement is used to structure the rows of your result set.

Syntax:

SELECT <columnExpression> [, <columnExpression> ...]


FROM <tableExpression>

Each column expression specifies how to populate the values in that particular column.

For example, you can select a column from the table referred to by tableExpression. Doing so populates
your result set with the values from the specified column in the table.

 Example

Let's assume we have the follow data (THIS_PROCESS):

case_id Customer ID Status Order Quantity

1 C_1023 Received 1

2 C_1198 Received 3

3 C_1212 Dispatched 2

SELECT "Customer ID"


FROM THIS_PROCESS

This query returns a result set with one column containing all the values from the process data's customer
ID column:

Customer ID

C_1023

C_1198

SAP Signavio Analytics Language Guide


10 PUBLIC SAP Signavio Analytics Language
Customer ID

C_1212

A column expression can also be a literal value. Such a value is repeated in that column for each row in the
result set.

 Example

SELECT case_id, 1
FROM THIS_PROCESS

This query creates a result set with two columns. The first column is populated with the values from
case_id in THIS_PROCESS. The second column is populated with the literal value 1.

case_id 1

1 1

2 1

3 1

You can also create column expressions by combining values, column names, operators or function calls.

 Example

SELECT "Customer ID", "Order Quantity" + 1


FROM THIS_PROCESS

In this query, the result set's second column is populated with the values from the "Order Quantity" column
in THIS_PROCESS, but in each case that value is increased by 1.

Customer ID "Order Quantity" + 1

C_1023 2

C_1198 4

C_1212 3

Selecting All Columns From a Process

You can use the * operator in a SELECT statement to select all columns of a table under the following
conditions:

• The query contains multiple SELECT statements.


• At least one of those SELECT statements references an explicit list of columns.

 Example

SELECT case_id,
"Customer ID",

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 11
"Order Quantity"
FROM (
SELECT *
FROM THIS_PROCESS
) AS sub

This query uses a subquery to select all columns from THIS_PROCESS. From them, the outer query then
selects an explicit subset of columns:

case_id Customer ID Order Quantity

1 C_1023 1

2 C_1198 3

3 C_1212 2

Including Clauses

When building a SIGNAL query, add any of the optional clauses in the order they appear in the syntax.

 Example

SELECT case_id, "Customer ID", "Order Quantity"


FROM table
ORDER BY 3 DESC
LIMIT 2

This query returns the case ID, customer ID and order quantity of the first 2 cases in the table. The clause
ORDER BY 3 DESC orders the result set by the third column in descending order.

case_id Customer ID Order Quantity

2 C_1198 3

3 C_1212 2

Related Information

Subqueries [page 44]

1.3.1 SELECT DISTINCT Clause

Learn about the SELECT (DISTINCT) clause in SIGNAL, the process mining query language of SAP Signavio
Process Intelligence.

The SELECT DISTINCT clause returns unique values of a specified column. If NULL values are present, they are
included. This function is not supported in subqueries.

SAP Signavio Analytics Language Guide


12 PUBLIC SAP Signavio Analytics Language
Syntax:

SELECT DISTINCT expression


FROM table

Parameter Description

expression The column, expression, or event-attribute that is returned.


If more than one expression is provided, separate the values
with a comma.

table The process table or view from which you want to retrieve
data. It is referenced by explicit Process ID or the alias
THIS_PROCESS.

Example 1: Get unique cities in your process

SELECT DISTINCT city


FROM THIS_PROCESS
ORDER BY 1 ASC

This query returns all unique city names from the city column in the default process view, sorted in ascending
order. Duplicate values are removed from the result set. Therefore every city name appears only once.

Example 2: Get unique event name sequences (variants) in your process

SELECT DISTINCT event_name AS "Event Name:"


FROM THIS_PROCESS

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 13
This query returns all unique event name sequences (also referred to as variants) from the event name column
in the default process view. Using AS “Event Name:” assigns a column alias to the result. The query is executed
at the case level which means that the event name sequences are represented as nested lists of event names.
Duplicate values are removed from the result set so that every event name sequence (nested list) only appears
once.

Example 3: Get only unique event names in your process

SELECT DISTINCT event_name AS "Event Name:"


FROM FLATTEN (THIS_PROCESS)

SAP Signavio Analytics Language Guide


14 PUBLIC SAP Signavio Analytics Language
ORDER BY 1 ASC

This query returns a unique list of event names in ascending order. Using AS “Event Name:” assigns a column
alias to the result. Using the FLATTEN expression flattens the nested event data in the process, thereby
representing each nested event as a single row containing case and event properties. Duplicate values are then
removed from the result set so that every event name only appears once.

1.3.2 FROM Clause

Learn about the FROM clause in SIGNAL, the process mining query language of SAP Signavio Process
Intelligence.

The FROM clause specifies the table in your process from which you want to retrieve the data.

THIS_PROCESS is the alias or temporary name assigned to the table that was set as default view in your
process. By default, the FROM clause fetches data from the default view.

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 15
Syntax:

FROM table

Parameter Description

table The process table or view from which you want to retrieve
records. You can reference the process by using the ex-
plicit Process ID which can be found on the API tab in the
process settings page. Alternatively you can use the alias
THIS_PROCESS to refer to the default view.

Example: Get list of unique cities from default view

To retrieve the list of unique cities available in your process, run the following query.

SELECT DISTINCT city


FROM THIS_PROCESS

The query returns the following result.

1.3.3 WHERE Clause

Learn about the WHERE clause in SIGNAL, the process mining query language of SAP Signavio Process
Intelligence.

The WHERE clause is used to filter the data and apply conditions to the SELECT statement. This lets you
retrieve subsets of table rows based on set conditions.

Syntax:

WHERE condition

SAP Signavio Analytics Language Guide


16 PUBLIC SAP Signavio Analytics Language
Parameter Description

condition The condition that must be met for records you want to
select.

Following are the common symbols used in WHERE clause:

Symbols

> (greater than)

< (less than)

>= (greater than or equal to)

<= (less than or equal to)

= (equal to)

!= (not equal to)

Example 1: Get the total purchase order amount

To retrieve the total order amount from the purchases made in the Boston city. This query retrieves the Order
Amount column values that match the WHERE condition.

SELECT SUM("ORDER AMOUNT")


FROM THIS_PROCESS
WHERE("City"='Boston')

This query returns the total order amount in Boston as 94,757.15.

Example 2: Using AND in the WHERE clause

To get the list of case Ids of the orders from Miami city with order status as delivered, run the following query.

SELECT case_id,"City", "Order Status"


FROM THIS_PROCESS
WHERE("ORDER Status"='Delivered' AND "City"='Miami')

The query returns the following result.

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 17
1.3.4 FILTER Clause

The FILTER clause is used to filter data inside aggregations. This lets you include or exclude specific cases or
events from aggregations in your query.

Syntax

FILTER (WHERE <condition>)

Parameter Description

condition A Boolean expression. Only cases or events for which this


expression evaluates to true are included in the aggregation.

Example

The following query finds the duration between two events: first receipt of an order and completion of payment
for that order. It does this by executing a subquery, querying event-level data. In obtaining the timestamp of the
final payment, only events named 'Receive Payment' are included by the filter. Because an order may include
multiple payments, LAST is applied to the resulting aggregation to obtain the latest timestamp.

SAP Signavio Analytics Language Guide


18 PUBLIC SAP Signavio Analytics Language
Similarly, the timestamp of the first event named 'Receive Customer Order' is queried. The difference between
the two timestamps gives the cycle time from order receipt to payment.

SELECT
case_id,
(SELECT LAST(end_time) FILTER (WHERE event_name = 'Receive Payment') -
FIRST(end_time) FILTER (WHERE event_name = 'Receive Customer Order')
) AS PaymentTurnaround
FROM THIS_PROCESS

Example output:

1.3.5 FILTER EVENTS Clause

Filter data from a result set at event-level.

This clause evaluates a given boolean expression on the event attributes and removes from the result set those
which evaluate to false. This stands in contrast to the WHERE statement, which removes entire cases from a
result set.

 Note

Because this clause removes events rather than entire cases, it's possible for a result set to include cases
with empty event lists. Refer to Example 3 [page 22] for a demonstration of how to remove such cases
from a result set.

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 19
Syntax

FILTER EVENTS WHERE <booleanExpression>

Parameter Description

booleanExpression The condition that an event must match to achieve inclusion


in the filtered result set.

 Restriction

MATCHES and BEHAVIOR MATCHES expressions can't be nested. Consequently, these expressions can't be
used in the booleanExpression of a FILTER EVENTS clause.

Clause Evaluation Order

If a query contains both a FILTER EVENTS clause and a WHERE clause, the FILTER EVENTS clause is
evaluated before the WHERE clause. Having this evaluation order enables the elimination of particular events
before cases as a whole are filtered further. Example 4 demonstrates this behavior.

The expressions defined in the FILTER EVENTS and WHERE clauses are evaluated after the FROM clause.
Consequently, using event-level filtering in combination with the FLATTEN operator isn't possible because
flattening transforms all event-level columns to case level.

 Tip

As an alternative, you can use event-level filtering in a subquery and then flatten the result.

Referencing Case and Event-Level Attributes

The booleanExpression can reference both case and event-level attributes. Refer to Example 2 for a
demonstration.

Usage of the FILTER EVENTS clause requires that an event-level attribute appears in at least one of the
following (otherwise, an error is returned):

• The set of columns selected as part of the query or subquery


• A follow-up operator, such as a WHERE clause

SAP Signavio Analytics Language Guide


20 PUBLIC SAP Signavio Analytics Language
Example 1

Given the following data (THIS_PROCESS):

The following query filters out all events where the payment amount is greater than 300.

SELECT
case_id,
"Order Amount",
event_name,
"Payment Amount"
FROM "THIS_PROCESS"
FILTER EVENTS WHERE "Payment Amount" > 300

Output:

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 21
Notice how cases 00008 and 00009 have empty event lists since they have no events fulfilling the FILTER
EVENTS condition.

Example 2

Using the same process data as the previous example, the following query demonstrates how both case and
event-level attributes can be included in a FILTER EVENTS clause.

SELECT
case_id,
"Order Amount",
event_name,
"Payment Amount"
FROM "THIS_PROCESS"
FILTER EVENTS WHERE "Payment Amount" < "Order Amount"

As the example data shows, all orders were paid for in one complete payment with the exception of case
'00009', which was paid for in two smaller installments. Therefore, this query filters out all events except the
payment-related events of case '00009'.

Example 3

Event-level filtering can leave behind cases with empty event lists. To filter out such cases, combine the FILTER
EVENTS clause with a WHERE clause as in the following query (which adapts the query from Example 2):

SELECT
case_id,
"Order Amount",
event_name,
"Payment Amount"
FROM "THIS_PROCESS"
FILTER EVENTS WHERE "Payment Amount" < "Order Amount"
-- Eliminate empty event lists
WHERE (SELECT COUNT(event_name) > 0)

This method takes advantage of every event automatically having an event_name attribute. Event lists
featuring no event_name can therefore be considered as empty.

SAP Signavio Analytics Language Guide


22 PUBLIC SAP Signavio Analytics Language
Example 4

Again using the process data from Example 1, this query further demonstrates combining the FILTER EVENTS
and WHERE clauses.

SELECT
case_id,
"Order Amount",
event_name,
"Payment Amount"
FROM "THIS_PROCESS"
FILTER EVENTS WHERE event_name IN ('Receive Customer Order', 'Receive Payment',
'Receive Delivery Confirmation')
WHERE event_name MATCHES (^'Receive Customer Order' -> 'Receive Payment' ->
'Receive Delivery Confirmation')

The FILTER EVENTS clause keeps only those events named 'Receive Customer Order', 'Receive Payment', or
'Receive Delivery Confirmation'. The containing cases are filtered further by the WHERE clause, which uses a
matching expression. Only cases whose event lists follow an expected pattern are kept, that pattern being:

1. Receiving an order
2. Receiving a single payment
3. Receiving delivery confirmation

All cases follow this pattern apart from case '00009', which, as earlier examples showed, involves multiple
payments.

Related Information

FLATTEN Operator [page 39]

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 23
Matching Expressions [page 62]
WHERE Clause [page 16]

1.3.6 GROUP BY Clause

Groups rows by one or more columns and computes aggregate functions for each group.

Columns are referred to by a number, which reflects their position in the SELECT clause. For example, GROUP
BY 2 groups the result by the second expression in the SELECT clause. All rows that share the same values for
the grouped expression are condensed into a single row.

Syntax

GROUP BY <columnIndex> [, ...]

Parameter Description

columnIndex The position in SELECT clause of the column being grouped


by. The indexing is 1-based, so the first column has position
1.

 Remember
In a GROUP BY clause, you cannot refer to columns by
their name.

Grouping and Aggregations

The GROUP BY clause is often used with aggregate functions, such as COUNT, MAX, or AVG. The aggregate
function is computed across all rows of each group and returns a separate value for each group. To specify the
rows to be considered for the aggregation, you can apply the FILTER clause to the aggregate function.

The GROUP BY clause is optional. If the GROUP BY clause is not present, then the following applies:

• If there are aggregate and non-aggregate expressions in the SELECT statement, then the result is
automatically grouped by any non-aggregate expressions.
• If there are only aggregate expressions in the SELECT statement, then the result is a single group
comprising all the selected rows.

If the GROUP BY clause is present, then the following applies:

• You must group by all expressions in the SELECT statement that are not encapsulated by an aggregate
function. Exception: The ungrouped expression is functionally dependent on a grouped expression (see
Example 2).

SAP Signavio Analytics Language Guide


24 PUBLIC SAP Signavio Analytics Language
• You can't group by an expression that contains an aggregate function.

Grouping by Events

If a case-level attribute is chosen for the grouping, the result set is grouped according to the values present in
that attribute. If an event-level attribute is chosen, the result set is grouped by the list of identical sequences of
events. This can be used to identify process variants.

Example 1

SELECT city, region, COUNT(case_id)


FROM THIS_PROCESS
GROUP BY 1, 2

GROUP BY 1, 2 groups by the expressions in the SELECT statement that are not encapsulated by an
aggregation function. Since this SELECT statement contains two expressions (city and region), the GROUP
BY index must refer to both expressions. GROUP BY 1 or GROUP BY 2 is not valid in this case.

Example 2

To get the count of case ids with actual order amounts and order amounts multiplied 2.50 times, run the
following query.

SELECT "Order Amount", ("Order Amount"*2.50) AS "Orders", COUNT(case_id) AS


"No.of Cases"
FROM THIS_PROCESS
GROUP BY 1, 2

Since the second expression order_amount*2.50 is functionally dependent to the first colum
order_amount, GROUP BY 1 is valid in this case.

The query returns the following result.

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 25
Related Information

Aggregate Functions [page 84]


FILTER Clause [page 18]

1.3.7 ORDER BY Clause

Sorts the result set in ascending or descending order.

 Caution

For very large data sets, this operator may require excessive CPU activity, causing long query execution
times.

For more information, refer to Performance [page 209].

Syntax

ORDER BY <columnIndex> [ { ASC | DESC } ] [ NULLS { FIRST | LAST } ] [, ... ]

SAP Signavio Analytics Language Guide


26 PUBLIC SAP Signavio Analytics Language
Parameter Description

columnIndex The index of a column used to sort the records in the result
set. If more than one expression is provided, separate the
values with a comma.

The index is 1-based, meaning that the first column is refer-


red to as 1.

Additional keywords can be added to influence the sorting:

• The direction of sorting: ASC sorts the column in ascending order. DESC sorts it in descending order. If
neither keyword is specified, the default sorting is ascending.
• The position of NULL values: NULLS FIRST sorts a column so that NULL values are presented first. NULLS
LAST sorts a column so that NULL values are presented last. If neither is specified, the default position is
NULLS FIRST.

Example

SELECT case_ID AS "Case IDs", "Order Amount", "Customer Type"


FROM THIS_PROCESS
ORDER BY 2 DESC

This query returns cases in the process sorted by the order amount in descending order.

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 27
1.3.8 FILL Clause

The FILL clause fills any gaps inside a time series column. It does so by inserting new rows into the result set,
each containing missing timestamps.

As part of the fill, the precision must be specified. Assume, for example, you specify a precision level of 'days'. If
the time series column contains the values 'Mon, 4th September 2023' and 'Thu, 7th September 2023' with no
intervening values, then two rows would be inserted containing the missing dates ('Tue, 5th September 2023'
and 'Wed, 6th September 2023') in the time series column.

This precision level is part of a larger fill specification you need to provide, which instructs SIGNAL how to
populate the columns in all inserted rows.

Syntax

SELECT <columnExpression> [, <columnExpression> ...]


FROM <tableExpression>
FILL <fillSpecification> [, <fillSpecification >... ]

Parameter Description

columnExpression A column or value to be selected.

tableExpression The process table or view from which you want to retrieve
records, referenced by explicit Process ID or the alias
THIS_PROCESS.

fillSpecification A fill specification for the corresponding column expression.

 Note
The number of fill specifications provided must equal
the number of columns selected. Under certain circum-
stances, missing specifications are added automatically.
See Writing Fill Specifications [page 28] for more infor-
mation.

Writing Fill Specifications

A fill specification takes one of the following values:

• TIMESERIES(<precision>): Defines the precision of the filling, determining with what regularity missing
entries are filled in the time series. Exactly one fill specification must be a TIMESERIES.
The precision parameter accepts a string literal specifying the precision level. The following levels are
supported:
• 'year'

SAP Signavio Analytics Language Guide


28 PUBLIC SAP Signavio Analytics Language
• 'quarter'
• 'month'
• 'week' (ISO 8601-week numbering is applied)
• 'day'
• 'hour'
• GROUP: In the corresponding column, newly added rows are filled by repeating the same value for the
whole group. A fill specification can include at most one GROUP. Learn more in the following section, Using
GROUP [page 30].
• NULL: Enters a NULL value into the corresponding column for all new rows.

Each fill specification matches with the column at the same index. In other words, the first specification in the
FILL clause corresponds to the first column in the SELECT clause, the second specification corresponds to the
second column, and so on.

SELECT
col1,
col2,
col3
FROM THIS_PROCESS
FILL
TIMESERIES('day'), -- corresponds to col1
GROUP, -- corresponds to col2
NULL -- corresponds to col3

Each column must have a fill specification. Any specifications you fail to provide are assumed to be of type
NULL and implicitly added to the end of the FILL clause. Therefore, the following query is equivalent to the
previous query:

SELECT
col1,
col2,
col3
FROM THIS_PROCESS
FILL
TIMESERIES('day'),
GROUP
-- NULL added here implicitly

However, if a NULL specification falls between TIMESERIES and GROUP specifications, then the NULL
specification must be added explicitly.

SELECT
col1,
col2,
col3
FROM THIS_PROCESS
FILL
TIMESERIES('day'),
NULL,
GROUP

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 29
Using GROUP

The FILL clause isn't only useful for filling missing timestamps in the overall result set. It can also group the
values in a specified column and then add rows containing all missing timestamps to each group.

 Remember

At most one column can be specified as a GROUP in a FILL clause.

 Example

Assume we have the following process data (THIS_PROCESS):

City Customer Type Received

Boston Standard 2020-01-01

New York Premium 2020-01-02

San Francisco Standard 2020-01-04

If we fill the time series with missing dates without specifying a GROUP column, then the missing dates are
added independently of the other columns. The newly added rows would therefore be populated with NULL
values in all other columns.

SELECT
Received,
City,
"Customer Type"
FROM THIS_PROCESS
FILL TIMESERIES('day')

This query returns the following output:

By specifying City as a group, all missing dates are added for each group of cities. Within each group, the
value of City is repeated for each inserted row.

SELECT
Received,
City,
"Customer Type"
FROM THIS_PROCESS
FILL TIMESERIES('day'), GROUP

SAP Signavio Analytics Language Guide


30 PUBLIC SAP Signavio Analytics Language
This query returns the following output:

Using GROUP BY and ORDER BY

The GROUP BY clause is applied after the filling. It's not related to the GROUP fill specification.

The FILL clause influences the definition and output of the ORDER BY clause. The FILL clause returns the
filled time series for each group (as defined by the GROUP specification) in ascending order. Consequently, in
the ORDER BY clause, the group column must be followed by the ascending time series column (as defined by
TIMESERIES(<precision>)).

 Note

If no ORDER BY is provided, the output is first grouped by the GROUP specified column and then by the
TIMESERIES specified column.

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 31
Example

This example builds a query for showing the types of orders received on a daily basis. An overview of every day
should be shown but not every type of order is sold every day, so we use FILL to fill any gaps. There are two
types of customer: 'Standard' and 'Premium'.

SELECT
DATE_TRUNC('day', (SELECT FIRST(end_time))) AS "Date",
"Customer Type"
FROM THIS_PROCESS
GROUP BY 1, 2

Result:

As the output shows, no premium customers made orders on 1 January.

The next step is to add extra rows for each missing order type on each day. Specifically, we group the values in
the Customer Type column into two groups and then add new rows for the missing days within each group. The
value for the Customer Type column in the new rows takes the value of the current group.

To do that, add a FILL clause. TIMESERIES('day') identifies the first column as the time series. GROUP
identifies the Customer Type as the group column.

SELECT
DATE_TRUNC('day', (SELECT FIRST(end_time))) AS "Date",
"Customer Type"
FROM THIS_PROCESS
GROUP BY 1, 2
FILL
TIMESERIES('day'),
GROUP

SAP Signavio Analytics Language Guide


32 PUBLIC SAP Signavio Analytics Language
Result:

Finally, we select the number of orders for each group on each date. The corresponding fill specification is
NULL, meaning that column is filled with null values in the new rows.

SELECT
DATE_TRUNC('day', (SELECT FIRST(end_time))) AS "Date",
"Customer Type",
COUNT(case_id)
FROM THIS_PROCESS
GROUP BY 1, 2
FILL
TIMESERIES('day'),
GROUP,
NULL

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 33
The result shows the number of each order type on a daily basis:

Related Information

COUNT [page 91]


DATE_TRUNC [page 132]
FIRST [page 93]

SAP Signavio Analytics Language Guide


34 PUBLIC SAP Signavio Analytics Language
1.3.9 LIMIT Clause

Learn about the LIMIT clause in SIGNAL, the process mining query language of SAP Signavio Process
Intelligence.

With the LIMIT clause, you can specify the number of rows to return. Normally, you use this clause together
with the ORDER BY clause.

Without a LIMIT clause, the result set is limited to 500 rows by default. By setting the LIMIT clause, you can
decrease or increase the default limit.

Syntax:

SELECT expression
FROM table
LIMIT number

Parameter Description

expression The column or expression that you want to retrieve.

table The process table or view from which you want to retrieve
records, referenced by explicit Process ID or the alias
THIS_PROCESS.

number The number of rows in the result set.

Example:

SELECT "Customer ID", case_id AS "Case ID","Order Status", city AS "City"


FROM THIS_PROCESS
WHERE ("city"='Boston')
ORDER BY 1 DESC
LIMIT 10

This query returns the first 10 rows where the customer Ids are sorted in descending order. It returns the
customer IDs with orders from only Boston city.

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 35
1.3.10 TABLESAMPLE Clause

Learn about the TABLESAMPLE clause in SIGNAL, the process mining query language of SAP Signavio Process
Intelligence.

With the TABLESAMPLE clause, you can specify either the absolute or percentage table fraction to be
considered for the query. The table fraction is sampled randomly after the FROM clause is evaluated and
before all other clauses.

Syntax:

SELECT expression
FROM table
TABLESAMPLE sampling method (sampling amount) REPEATABLE (seed
)

Parameter Description

expression The column or expression that you want to retrieve.

table The process table or view from which you want to retrieve
records, referenced by explicit Process ID or the alias
THIS_PROCESS.

sampling method The sampling method. Currently, only EXACT is supported.

sampling amount The sampling amount; either absolute or percentage.

SAP Signavio Analytics Language Guide


36 PUBLIC SAP Signavio Analytics Language
Parameter Description

seed The optional seed number to be used for generating random


numbers for the sampling method.

Example:

SELECT "Order Amount in EUR", "Duration Order To Payment"


FROM (
SELECT
"Order Amount in EUR",
(SELECT LAST (end_time) FILTER (WHERE event_name = 'Receive Payment')) -
(SELECT FIRST (end_time) FILTER (WHERE event_name = 'Receive Customer
Order')) AS "Duration Order To Payment"
FROM THIS_PROCESS
WHERE
("Order Amount in EUR" IS NOT NULL)
AND
((SELECT LAST (end_time) FILTER (WHERE event_name = 'Receive Payment')) -
(SELECT FIRST (end_time) FILTER (WHERE event_name = 'Receive Customer
Order'))
IS NOT NULL)
) AS sub_query
TABLESAMPLE EXACT(10 ROWS) REPEATABLE(123)

This query returns 10 rows sampled randomly from the specified table.

For TABLESAMPLE EXACT(10 PERCENT) REPEATABLE(123), the query returns 10 percent of the rows
sampled randomly from the specified table.

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 37
1.3.11 OFFSET Clause

Learn about the OFFSET clause in SIGNAL, the process mining query language of SAP Signavio Process
Intelligence.

With the OFFSET clause, you can specify the starting point to return rows from a result set.

Syntax:

SELECT expression
FROM table
LIMIT number
OFFSET offset_number

Parameter Description

expression The column or expression that you want to retrieve.

table The process table or view from which you want to retrieve
records, referenced by explicit Process ID or the alias
THIS_PROCESS

number The number of rows in the result set.

offset_number The amount or rows to skip from the top of the table.

SAP Signavio Analytics Language Guide


38 PUBLIC SAP Signavio Analytics Language
For the OFFSET to provide consistent results, you need to add ORDER BY clause in the query.

Example: OFFSET clause with ORDER BY and LIMIT clauses

SELECT case_id AS "Case ID", "Order Amount", "Customer ID"


FROM THIS_PROCESS
ORDER BY 2 DESC
LIMIT 5
OFFSET 10

This query returns the discounts in row 11 to 16.

1.3.12 FLATTEN Operator

Flattens a table so that each event attribute becomes a top-level row. Case attributes are repeated accordingly.

 Caution

For very large data sets, this operator may require excessive CPU activity, causing long query execution
times.

For more information, refer to Performance [page 209].

The following example shows a typical table before being flattened:

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 39
The same table after being flattened:

The flattened table allows aggregations based on event names or other event attributes.

 Remember

Do not combine the FLATTEN operator with the MATCHES operators. The MATCHES operators work only with
nested tables and not with flattened tables.

Syntax

FLATTEN(<tableName>)

Example 1

This query flattens a table.

SELECT case_id, "Customer ID", "Order Status", "City", "event_name", "end_time"


FROM FLATTEN (THIS_PROCESS)

Example 2

Count the number of cases that include a specific event.

SELECT COUNT (DISTINCT case_id), "event_name"


FROM FLATTEN (THIS_PROCESS)
GROUP BY 2

This query returns the total number of cases in which each event occurs.

SAP Signavio Analytics Language Guide


40 PUBLIC SAP Signavio Analytics Language
1.3.13 UNION ALL Clause

Learn about the UNION ALL operator in SIGNAL, the process mining query language of SAP Signavio Process
Intelligence.

With the UNION ALL operator, you can combine the result sets of two or more SELECT statements. The
amount of table columns and column data types must match for each SELECT statement when using the
UNION ALL operator.

Syntax:

SELECT expression
FROM tables
[WHERE conditions]
TABLESAMPLE sampling method (sampling amount) REPEATABLE (seed)
ORDER BY order_index [, ...] [ASC | DESC] [NULLS FIRST | NULLS LAST]
UNION ALL
SELECT expression
FROM tables
[WHERE conditions]
TABLESAMPLE sampling method (sampling amount) REPEATABLE (seed)
ORDER BY order_index [, ...] [ASC | DESC] [NULLS FIRST | NULLS LAST]

Parameter Description

expression The column or expression that is queried.

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 41
Parameter Description

tables The tables from which you want to retrieve records. At least
one table must be listed in the FROM clause.

conditions (Optional) Conditions that must be met in order for the re-
cords to be selected.

SELECT statements before and after UNION ALL can only have the following clauses:

SELECT expressions
FROM table
[TABLESAMPLE]
[WHERE]
[GROUP BY]

Any other clauses, for example the UNION ALL, ORDER BY, FILL, LIMIT, and OFFSET are applied to the result of
UNION ALL.

Example 1:

SELECT case_id AS "Case ID"


FROM
(
SELECT case_id
FROM THIS_PROCESS
UNION ALL
SELECT case_id
FROM THIS_PROCESS
) as sub
ORDER BY 1
LIMIT 20

This query returns a combined result set of the case_ids from tables in a column.

SAP Signavio Analytics Language Guide


42 PUBLIC SAP Signavio Analytics Language
Example 2:

SELECT case_id, ts, is_first


FROM
(
SELECT
case_id,
DATE_TRUNC('day', (SELECT FIRST(end_time))) AS ts,
1.0 AS is_first
FROM THIS_PROCESS
UNION ALL
SELECT
case_id,
DATE_TRUNC('day', (SELECT LAST(end_time)) + DURATION '1day') AS ts,
0.0 as is_first
FROM THIS_PROCESS
) AS sub
ORDER BY 1,2,3
LIMIT 20

This query returns a combined result set of dates where an event was either open or closed on the given date.
A time-stamp (ts) is used, where 1 means the event is open and 0 means the event is closed on the respective
dates.

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 43
1.4 Subqueries

A subquery is a query that is nested inside another query.

There are two types of subquery: general and event-level. They differ based on the level at which they operate,
and what types of data they return.

• General subqueries operate at case level and return tables.


• Event-level subqueries operate at event level and return scalar values.

They follow this general syntax:

SELECT (<eventLevelSubquery>) [, <columns> ...]


FROM (<generalSubquery>) AS <alias>
WHERE <expression> (<eventLevelSubquery>)

Related Information

Event-Level Subqueries [page 47]


General Subqueries [page 45]

SAP Signavio Analytics Language Guide


44 PUBLIC SAP Signavio Analytics Language
1.4.1 General Subqueries

General subqueries operate at case level and return tables. They're used in combination with the FROM clause
and are useful for adapting result sets before selecting from them.

Syntax

The syntax of a general subquery follows that of a standard query. The difference comes from its placement.

This is the partial syntax of a query:

SELECT <columnExpression> [, <columnExpression> ...]


FROM { table | (<generalSubquery>) AS <alias>}

Parameter Description

columnExpression The value or expression selected as a column in the result.

generalSubquery A query that returns a table.

alias An identifying label for the subquery.

 Remember
A general subquery always needs an alias, otherwise the
query is invalid.

A general subquery follows the same syntax. However, the subquery is part of a FROM statement, providing
to its containing query a table from which to select data. As it builds the table, the subquery can adapt the
contents, for example by filtering or applying functions, providing the outer query with a customized data set.

Because a general subquery follows this same syntax, it's possible for a subquery to also select from a further
nested subquery. This recursive behavior allows you to nest subqueries to an arbitrary extent.

Examples

The following example demonstrates using a general subquery.

 Example

This query uses a general subquery to group orders by city and calculate their number. From the resulting
table, only those rows having a number of cases greater than 500 are selected.

SELECT "City", "Cases"


FROM (
SELECT "City", COUNT(1) AS "Cases"
FROM THIS_PROCESS
GROUP BY 1
) AS grouped_cities

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 45
WHERE "Cases" > 500

A general subquery can select from either a table, such as THIS_PROCESS, or from another nested subquery.
This nested subquery might in turn select from a further nested subquery and so on. Let's look at an example.

 Example

The following query shows the average payment amounts per city:

SELECT
"City",
AVG("Order Amount") AS "avg_payment"
FROM THIS_PROCESS
GROUP BY 1

Output:

Developing this further, the next query shows only the average payment amounts per city above a certain
amount.

SELECT
"City",
avg_payment
FROM (
-- sub1 begins here
SELECT
"City",
avg_payment

SAP Signavio Analytics Language Guide


46 PUBLIC SAP Signavio Analytics Language
FROM (
-- sub2 begins here
SELECT
"City",
AVG("Order Amount") AS "avg_payment"
FROM THIS_PROCESS
GROUP BY 1
) as sub2
WHERE avg_payment > 375
) as sub1

The initial query has now become the innermost subquery (sub2). Its containing query, which is itself a
subquery (sub1), adapts the data further by filtering out the cases where average payment is equal to or
below 375. This provides the table for the outermost query to select from.

Output:

1.4.2 Event-Level Subqueries

Event-level subqueries operate on event data and return scalar values. They're usually used with SELECT or
WHERE statements.

Syntax

(SELECT <columnExpression> [, <columnExpression> ...] [ FROM


<eventLevelSubquery> ] ) AS <alias>

Parameter Description

columnExpression Value or expression selected as a column in the result.

eventLevelSubquery An optional nested event-level subquery that returns a value


to the current subquery. For further information, refer to
section Nesting.

alias An identifying label for the subquery. For further informa-


tion, refer to section Nesting.

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 47
Event-level subqueries are actually expressions, meaning they can be used wherever expressions can be used.
For example, they can be used as column expressions in a standard query:

SELECT case_id,
(SELECT LAST(end_date))
FROM THIS_PROCESS

In this example, the second column is chosen using an event-level subquery. For each case in the process, this
subquery drops into event-level and selects from the case's event table. In this example, the column end_date
is selected. Because an event-level subquery returns scalar values, the aggregation function LAST is used to
return only the timestamp of the case's latest event, rather than a whole column of timestamps.

Nesting

An event-level subquery may optionally provide its own FROM clause.

• If included, this clause defines a nested event-level subquery for the containing subquery to select from.
• If a subquery doesn't include a FROM clause, it selects data from the table defined in the FROM clause of the
outermost query.

Nesting of event-level subqueries can be done to an arbitrary extent:

(SELECT <cols> FROM


(
...
(SELECT <cols> FROM
(SELECT <cols>) AS <alias>
) AS <alias>
...
) [AS <alias>]

When nesting event-level subqueries, note the following:

• The innermost subquery doesn't require a FROM clause. It selects data from the table defined in the
outermost query's FROM clause.
• All subqueries require an alias, the exception being the outermost subquery (where an alias is optional).
• A nested subquery doesn't need to use another event-level subquery to access event-level attributes. It
already operates at event-level by virtue of being nested. Example 3 demonstrates this.

Example 1

The following query selects the ID of each case and uses an event-level subquery to access each case's event
data. The subquery must return a scalar value, which in this example is the difference between the latest and
earliest timestamps. Since it's already the innermost subquery, no FROM clause is necessary.

SELECT
case_id,
(SELECT LAST("end_time") - FIRST("end_time")) AS "Turnaround Time"
FROM THIS_PROCESS

SAP Signavio Analytics Language Guide


48 PUBLIC SAP Signavio Analytics Language
Output:

Example 2

Event-level subqueries can also be used in combination with the WHERE statement to filter out cases based on
event attributes. In this example, payments are event-level data since several payments can be made per order.
When an order is canceled, the last event in that case is 'Order Canceled'.

SELECT case_id, (SELECT SUM("Payment Amount")) AS "Total Payment"


FROM THIS_PROCESS
WHERE (SELECT LAST(event_name)) <> 'Order Canceled'

This example uses two event-level subqueries.

• The first (in the SELECT clause) selects all payment amounts per case and sums them, yielding the total of
that order.
• The second (in the WHERE clause) selects the last event in each case and filters out those orders that were
canceled.

Output:

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 49
Example 3

An event-level subquery can contain a nested subquery, as demonstrated in this example for finding the lowest
payment received per order.

-- Outermost query
SELECT
case_id,
(
-- Subquery
SELECT MIN("Payment Amount")
FROM (
-- Nested subquery
SELECT "Payment Amount"
WHERE event_name = 'Receive Payment'
) as sub
) AS "Lowest Payment"
FROM THIS_PROCESS

The nested subquery, being the innermost, selects from the table defined by the outermost query
(THIS_PROCESS) and provides a list of payment amounts for the current order. The containing subquery
selects the minimum value from this list, thus finding the lowest payment and meeting its requirement to
return a scalar value.

Output:

1.5 Expressions

In SIGNAL, an expression is a combination of values, operators and functions which is evaluated to return a
single value.

SIGNAL provides the following types of expressions:

Arithmetic Expressions [page 51]


Use arithmetic expressions to execute mathematical operations on numeric values.

Comparison Expressions [page 55]

SAP Signavio Analytics Language Guide


50 PUBLIC SAP Signavio Analytics Language
Comparison expressions evaluate to logical true or false by comparing the values of two expressions.

Logical Expressions [page 58]


A logical expression connects Boolean expressions using logical operators and can be evaluated to
return a true or false value.

Matching Expressions [page 62]


Matching expressions recognize patterns in event-level values, returning true if a given pattern matches
or false otherwise.

LIKE and ILIKE Expressions [page 69]


Search for a specified string pattern in a column.

Conditional Expressions [page 74]


Conditional expressions return values dependent on the evaluation of boolean conditions.

Expressions for NULL Values [page 79]


Evaluate expressions involving NULL values.

Literal Expressions [page 81]


A literal is a fixed value of a certain type. SIGNAL supports literals of several different types.

1.5.1 Arithmetic Expressions

Use arithmetic expressions to execute mathematical operations on numeric values.

The following arithmetic operators are available:

Operator Description

+ Add

– Subtract

* Multiply

/ Divide

% Modulo

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 51
Syntax

Type information

expression1 + expression2
Number + Number = Number

Time- + Duration = Time-


stamp stamp

Duration + Time- = Time-


stamp stamp

Duration + Duration = Duration

expression1 - expression2
Number – Number = Number

Time- – Time- = Duration


stamp stamp

Time- – Duration = Time-


stamp stamp

Duration – Duration = Duration

expression1 * expression2
Number * Number = Number

Number * Duration = Duration

Duration * Number = Duration

expression1 / expression2
Number / Number = Number

Duration / Number = Duration

Duration / Duration = Number

expression1 % expression2
Number % Number = Number

Operator Precedence

These operators follow the standard mathematical order of operations. This means:

• Evaluation proceeds from left to right. For example, 9 - 5 + 2 is interpreted as (9 - 5) + 2 = 6 rather than 9 -
(5 + 2) = 2.
• Evaluation is performed in order of precedence (from higher to lower). For example, 5 + 2 * 2 is interpreted
as 5 + (2 * 2) = 9 rather than (5 + 2) * 2 = 14.

SAP Signavio Analytics Language Guide


52 PUBLIC SAP Signavio Analytics Language
Example 1

This query subtracts the order quantity from the shipment quantity, calculating any difference between an
order's size and the total number of goods actually dispatched.

SELECT case_id, (SELECT SUM("Shipment Quantity")) - "Order Quantity" AS Diff


FROM THIS_PROCESS

Result (canceled orders, where no delivery took place, have no number displayed):

Example 2

This query divides each payment received by the total amount of the order and multiplies by 100. The resulting
figure is the percentage of the full amount each individual payment represents.

SELECT
case_id,
"Payment Amount" / "Order Amount" * 100 AS "Proportion %"
FROM FLATTEN(THIS_PROCESS)
WHERE event_name = 'Receive Payment'

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 53
Result:

Example 3

This query returns the remainder when dividing the shipment quantity by 15. Assuming goods from an order
are shipped in containers with a capacity of 15, this query calculates how many units were shipped in a non-full
container.

SELECT "Shipment Quantity" % 15 AS "Units shipped in non-full container"


FROM FLATTEN(THIS_PROCESS)
WHERE ("Shipment Quantity" IS NOT NULL)

SAP Signavio Analytics Language Guide


54 PUBLIC SAP Signavio Analytics Language
Result:

1.5.2 Comparison Expressions

Comparison expressions evaluate to logical true or false by comparing the values of two expressions.

The following comparison operators are available:

Operator Description

< Less than

> Greater than

<= Less than or equal to

>= Greater than or equal to

= Equal to

<> Not equal to

Syntax

expression1 = | <> | < | <= | > | >= expression2

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 55
Parameters Description

expression1 The first expression to be compared.

expression2 The second expression to be compared.

Type Information

This table summarizes which combinations of data types are valid with the various comparison operators and
what type of result each combination yields.

Type of expression1 Type of expression2 Valid Operators Result Type

Number Number =, <>, <, <=, =>, > Boolean

Timestamp Timestamp =, <>, <, <=, =>, > Boolean

Duration Duration =, <>, <, <=, =>, > Boolean

Text Text =, <> Boolean

Boolean Boolean =, <>, <, <=, =>, > Boolean

 Note

When comparing Boolean types, false < true.

Example 1

The following example query uses the comparison operations, '>', '<', and '=' for defining conditions in the
WHERE clause. It returns a list of delivered orders whose order amount is between 100 and 900. If the order
status is 'Delivered' and the order amount is greater than 100 and less than 900, then the query returns the
case IDs of these orders along with other details.

SELECT case_id, "order amount", "Order Status"


FROM THIS_PROCESS
WHERE ("ORDER Status" = 'Delivered' AND "order amount" > 100 AND "order amount"
< 900)
LIMIT 10

Result:

The query returns the following result.

SAP Signavio Analytics Language Guide


56 PUBLIC SAP Signavio Analytics Language
Example 2

The following example query uses the comparison operations, '>=', '<=', and '<>' for defining conditions in the
WHERE clause. It returns a list of orders that are not delivered and with the order amount between 300 and
2000. If the order status is not 'Delivered' and the order amount is greater than or equal to 300 and less than
or equal to 2000, then the query returns the case IDs of these orders along with other details.

SELECT "case_id", "ORDER AMOUNT" AS "Orders between 300to2000", "order status"


FROM THIS_PROCESS
WHERE ("order amount" >= 300 AND "order amount" <= 2000 AND "Order status" <>
'Delivered')
LIMIT 10

Result:

The query returns the following result.

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 57
1.5.3 Logical Expressions
A logical expression connects Boolean expressions using logical operators and can be evaluated to return a
true or false value.

The following logical operators are available:

Operator Description

AND True if all the expressions separated by AND are true.

NOT Negates the expression.

OR True if any of the expressions separated by OR is true.

AND, OR

Syntax:

<expression1> AND <expression2>

SAP Signavio Analytics Language Guide


58 PUBLIC SAP Signavio Analytics Language
<expression1> OR <expression2>

Parameters Description

expression1 The first expression to be evaluated.

expression2 The second expression to be evaluted.

Operator Precedence

These two operators have different operator precedence. Specifically, AND takes precedence over OR. In
compound expressions including both operators, this means that AND operations are evaluated before OR
operations. For example, A OR B AND C is interpreted as A OR (B AND C) by default.

To override this and force OR operations to take precedence, enclose the relevant part of the expression in
parentheses, for example, (A OR B) AND C.

NOT

Syntax:

NOT(<expression1>)

Parameters Description

expression1 The expression to be negated.

Type Information

This table summarizes which combinations of data types are valid with the various logical operators and what
type of result each combination yields.

Type of expression1 Type of expression2 Valid Operators Result Type

Boolean Boolean AND, OR Boolean

Boolean NOT Boolean

Example 1: Using AND Operator

The following example returns a list of delivered orders in the city of Boston. If the order status is delivered and
the city is Boston, then the query returns the case IDs of these orders along with other details.

SELECT case_id, "City", "Order Status", "order amount"


FROM THIS_PROCESS
WHERE ("ORDER Status" = 'Delivered' AND "City" = 'Boston')

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 59
LIMIT 10

Result:

The query returns the following result.

Example 2: Using OR Operator

The following example returns orders where the value is less than 50 OR the value is greater than 2000 and city
is Houston. Keep in mind the remark above noting how AND operations take precedence over OR operations.

SELECT case_id, "order amount", "Order Status", "city"


FROM THIS_PROCESS
WHERE ("Order amount" <= 50 OR "Order amount" >= 2000 AND "City" = 'Houston')
ORDER BY 2 DESC
LIMIT 15

Result:

The query returns the following result.

SAP Signavio Analytics Language Guide


60 PUBLIC SAP Signavio Analytics Language
Example 3: Using NOT Operator

The following example returns the total order amount of all purchases excluding orders from the cities, Boston
and Miami.

SELECT SUM("ORDER AMOUNT")


FROM THIS_PROCESS
WHERE NOT("City" = 'Boston' AND "City" = 'Miami')

Result:

The query returns the following result.

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 61
1.5.4 Matching Expressions

Matching expressions recognize patterns in event-level values, returning true if a given pattern matches or false
otherwise.

 Restriction

The MATCHES expressions work only for nested tables and not for flattened tables. Don't combine a
MATCHES expression with the FLATTEN operator.

MATCHES

The MATCHES expression allows filtering based on patterns that check for a certain sequence of event-level
values, such as event_name.

Syntax

<expression> MATCHES (<pattern>)

Parameter Description

expression The column or expression that is compared with the defined


pattern.

SAP Signavio Analytics Language Guide


62 PUBLIC SAP Signavio Analytics Language
Parameter Description

pattern The defined pattern with which the expression is compared.

Pattern syntax Description

A -> B "A" directly followed by "B"


(can be omitted)

A ~> B "A" indirectly or directly fol-


lowed by "B". Equivalent to A
ANY* B

^A Sequence starts with "A" in


any specific case

B$ Sequence ends with "B" in


any specific case

A ANY B "A" is followed by any single


value which is then followed
by "B"

A ANY* B "A" is followed by any num-


ber of values, which are then
followed by "B"

NULL Sequence contains "Null"


values

NOT A All values that are not "A"


(even if the sequence con-
tains A values)

A NOT B "A" directly followed by a


value that is not "B"

A NOT (B | C) "A" directly followed by a


value that is not "B" or "C"

(A | B) "A" or "B"

Example 1

Match cases where the first event is “Receive Customer Order” and the event “Receive Delivery Confirmation”
occurs at any point later on.

SELECT case_id, event_name


FROM THIS_PROCESS
WHERE event_name MATCHES(^'Receive Customer Order' ~> 'Receive Delivery
Confirmation')

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 63
Output:

Example 2

Match cases where exactly one event of any kind occurs between a payment being received and the order
being canceled.

SELECT case_id, event_name


FROM THIS_PROCESS
WHERE "event_name" MATCHES ('Receive Payment' ANY 'Order Canceled')

SAP Signavio Analytics Language Guide


64 PUBLIC SAP Signavio Analytics Language
Output:

BEHAVIOUR MATCHES

The BEHAVIOUR MATCHES expression checks whether complex behavior matches a pattern. Up to eight
behaviors can be combined. For each behavior an alias must be given. Behaviors can be specified using
comparison operators.

Syntax

BEHAVIOUR (<expression>) AS <alias_name> [, (<expression>) AS <alias_name>, ...]


MATCHES (<pattern>)

Parameter Description

expression The column or expression with a defined behavior that is


compared with the defined pattern.

alias_name The temporary name to assign.

Enclose the name in double quotes if it contains a character


that isn't a letter or digit.

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 65
Parameter Description

pattern The complex pattern the expression is compared with.

Pattern syntax Description

A -> B "A" directly followed by "B"


(can be omitted)

A ~> B "A" indirectly or directly fol-


lowed by "B". Equivalent to A
ANY* B

^A Sequence starts with "A" in


any specific case

B$ Sequence ends with "B" in


any specific case

A ANY B "A" is followed by any single


value, which is then followed
by "B"

A ANY* B "A" is followed by any num-


ber of values, which are then
followed by "B"

NOT A All values that are not "A"


(even if the sequence con-
tains A values)

A NOT B "A" directly followed by a


value that is not "B"

A NOT (B | C) "A" directly followed by a


value that is not "B" or "C"

(A | B) "A" or "B"

Example

Match cases where a small payment was followed at some point by a larger payment.

SELECT case_id, event_name, "Payment Amount"


FROM THIS_PROCESS
WHERE BEHAVIOUR
(event_name = 'Receive Payment' AND "Payment Amount" < 100) AS
changed_small_amount,
(event_name = 'Receive Payment' AND "Payment Amount" >= 100) AS
changed_large_amount
MATCHES (changed_small_amount ~> changed_large_amount)

SAP Signavio Analytics Language Guide


66 PUBLIC SAP Signavio Analytics Language
IN

Tests whether a value is equal to any value in a specified list. If so, then the whole expression evaluates to true,
otherwise it evaluates to false.

Syntax

<valueExpression> [NOT] IN (<value> [, <value> ...])

Parameter Description Type

valueExpression A column or expression that evaluates Any


to a single value.

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 67
Parameter Description Type

value A literal value. Any

 Note
The types of the values in the
list must match the type of
valueExpression.

Examples

Our example process data records sales of several types of items.

SELECT "Type of Goods"


FROM THIS_PROCESS
GROUP BY 1

You can use IN to select only a subset of those entries, as the following example does.

SELECT "Type of Goods"


FROM THIS_PROCESS
WHERE "Type of Goods" IN ('Cappy', 'Cappy with Print')
GROUP BY 1

Output:

SAP Signavio Analytics Language Guide


68 PUBLIC SAP Signavio Analytics Language
Let's take this example further. The following query uses IN to find the total number of items of headgear sold
– in other words, items whose type is 'Cappy' or 'Cappy with Print' – and compares it with the number of all
other types sold.

SELECT
SUM("Order Quantity") AS "Sold",
IF ("Type of Goods" IN ('Cappy', 'Cappy with Print'), 'Yes', 'No') AS
"Headgear?"
FROM THIS_PROCESS

The query gives each order a label called "Headgear?". If the value of the order's Type of Goods field matches
with either 'Cappy' or 'Cappy with Print', then the label becomes 'Yes'. Otherwise, the label becomes 'No'. The
SUM function totals the items in both categories.

1.5.5 LIKE and ILIKE Expressions

Search for a specified string pattern in a column.

Using LIKE and ILIKE expressions, you can search for a specified string pattern in a column with string data
type. The LIKE expression matches case-sensitive string patterns, whereas the ILIKE expression matches
case-insensitive string patterns.

Both of these expressions provide:

• flexible string comparison using special characters


• improved string filtering and bucketing
• flexible process variant filtering using MATCHES and BEHAVIOR MATCHES expressions

An optional keyword 'NOT' can be used along with LIKE and ILIKE expressions to search for the non-matching
string patterns.

Syntax

<expression> [NOT] LIKE <pattern>

<expression> [NOT] ILIKE <pattern>

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 69
Parameter Description

expression The string expression that is compared with the defined


pattern.

pattern The defined string pattern the expression is compared with.

The string pattern includes special characters percent (%)


and underscore (_) to conduct a character-by-character
comparison.

NOT An optional keyword that is used to negate the expression


matching.

The LIKE and ILIKE expressions take string as input and return boolean as output.

For example:

Expression Output

‘Amsterdam' LIKE 'A%' true

'Ibiza' ILIKE '%A' true

‘Boston' NOT LIKE 'B%' false

'Miami' NOT ILIKE '%I' false

Special Characters

The LIKE and ILIKE expressions use special characters to compare strings, character-by-character.

The following special characters can be used in conjunction with these expressions:

• The percent (%) wildcard represents zero, one, or multiple characters


• The underscore (_) wildcard represents one, single character
• The backslash (\) character represents the escape character

You can also combine these special characters in a pattern.

Special characters usage Description

ILIKE '%to%' Returns true if the matching string pattern contains "to" in
any case and in any position

Example: "Washington", "Boston", "Paolo Alto", "Stockton"

LIKE '_o%' Returns true if the matching string pattern contains "o" in
the second position

Example: "Boston", "Rostock"

SAP Signavio Analytics Language Guide


70 PUBLIC SAP Signavio Analytics Language
Special characters usage Description

ILIKE 'm__%' Returns true if the matching string pattern starts with "m" or
"M" and is at least 3 characters in length

Example: "Miami", "Munich"

ILIKE 'b%n' Returns true if the matching string pattern starts with "b" or
"B", and ends with "n" or "N"

Example: "Berlin", "bern", "Boston"

LIKE and ILIKE Expressions with MATCHES

You can also use the LIKE and ILIKE expressions with MATCHES and BEHAVIOR MATCHES expressions for
filtering nested data. For example, see Example 3 [page 72] and Example 4 [page 72].

Example 1

The following example displays the use of wildcards in the string pattern.

SELECT "Type of Goods", COUNT("Type of Goods")


FROM FLATTEN(THIS_PROCESS)
WHERE "Type of Goods" ILIKE '%with print'
ORDER BY 1

Result:

The query collects the “Type of Goods” that ends with the value 'with print'.

Example 2

The following example displays the use of escape character (\) in the string pattern.

SELECT "Type of Goods", case_id


FROM THIS_PROCESS
WHERE case_id LIKE “100\\%”
GROUP BY 1

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 71
Result:

The query returns the entries where the case_id value starts with 100, follows by a backslash character, and
ends with any characters or numbers in a SIGNAL table.

Example 3

The following example displays the use of ILIKE expression in MATCHES expression.

SELECT count(case_id)
FROM THIS_PROCESS
WHERE event_name MATCHES ('Receive Customer Order' ~> ILIKE '%print%' ~> ILIKE
'%ship%')

Result:

The query returns the count of case_ids from THIS_PROCESS where a print action occured, and where the
order was shipped either as standard or express.

Example 4

The following example displays the use of ILIKE expression in BEHAVIOR MATCHES expression.

SELECT count(case_id)
FROM THIS_PROCESS
WHERE
BEHAVIOR
(event_name == 'Receive Customer Order') as order_received,
(event_name ILIKE '%print%') as order_printed,
(event_ILIKE '%ship%') as order_shipped
MATCHES (order_received ~> order_printed ~> order_shipped)

SAP Signavio Analytics Language Guide


72 PUBLIC SAP Signavio Analytics Language
Result:

The query returns the count of case_ids from THIS_PROCESS where a print action occured, and where the
order was shipped either as standard or express.

Example 5

The following example displays the use of NOT LIKE expression.

SELECT DISTINCT(event_name)
FROM FLATTEN(THIS_PROCESS)
WHERE event_name NOT LIKE '%Purchase%'

Result:

The query selects the event_name from THIS_PROCESS where the event_name does not contain the string
'Purchase'.

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 73
1.5.6 Conditional Expressions

Conditional expressions return values dependent on the evaluation of boolean conditions.

This section provides you with the following conditional expressions:

• CASE WHEN expression [page 74]


• IF expression [page 77]

CASE WHEN

The CASE WHEN expression evaluates a list of conditions and returns a value when the first condition is met.
Once a condition is true, it stops reading and returns the result. If no conditions are true, it returns the value in
the ELSE clause. If the ELSE clause is not present, it returns a NULL value.

Each CASE statement must end with the END statement. The ELSE statement is optional, and provides a way
to capture values not specified in the WHEN/THEN statements.

The WHEN statement is evaluated in the following ways:

• If a match is found, then the corresponding result in the THEN statement is returned, and the evaluation
stops. Any further WHEN statements aren't evaluated.
• If no match is found and an ELSE statement is present in the expression, then the result in the ELSE
statement is returned.
• If no match is found, and no ELSE statement is present, then a NULL value is returned.

Syntax

CASE
WHEN <condition> THEN <result>
[WHEN <condition> THEN <result> ...]
[ELSE <defaultResult>]
END

Parameter Description

condition A boolean expression.

result The value that is returned if the corresponding condition


evaluates to TRUE.

defaultResult The value that is returned if none of the conditions evaluates


to TRUE.

The CASE WHEN expression can be used in the following clauses:

• SELECT
• WHERE

SAP Signavio Analytics Language Guide


74 PUBLIC SAP Signavio Analytics Language
The following comparison operators and keywords can be used in the WHEN clause:

Operator / Key words Example

<
WHEN "Order Amount" < '1000' THEN
'Approved'

>
WHEN "Order Amount" > '1000' THEN
'Approved'

<=
WHEN "Order Amount" <= '1000' THEN
'Approved'

>=
WHEN "Order Amount" >= '1000' THEN
'Approved'

=
WHEN "Order Amount" = '1000' THEN
'Approved'

<>
WHEN "Order Amount" <> '1000' THEN
'Rejected'

IN
WHEN "Country" IN ('Germany',
'France') THEN 'Europe'

NOT IN
WHEN "Country" NOT IN ('Germany',
'France') THEN 'Rest of the World'

Example 1

The following example selects countries based on regions. When a country is in a specific region (condition is
true), it's added to the region (result). If a country doesn't match any of the conditions, it's added to the ELSE
result "Rest of World".

SELECT DISTINCT
"Country",
CASE WHEN "Country" = 'USA' THEN 'North America'
WHEN "Country" = 'Germany' THEN 'EU'
WHEN "Country" = 'France' THEN 'EU'
WHEN "Country" = 'South Africa' THEN 'Africa'
ELSE 'Rest of World'
END AS "Region"
FROM THIS_PROCESS

Result:

The query returns which countries reside in which regions in a SIGNAL table.

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 75
Example 2

The following example compares the minimum and maximum values of customer satisfaction ratings (CSAT)
at an event level in a CASE WHEN expression.

SELECT "Country",
CASE WHEN (SELECT(MAX("CSAT"))) = (SELECT(MIN("CSAT"))) THEN 'None'
WHEN (SELECT(MAX("CSAT"))) - (SELECT(MIN("CSAT"))) <= 1 THEN 'Low'
WHEN (SELECT(MAX("CSAT"))) - (SELECT(MIN("CSAT"))) <= 3 THEN 'Medium'
ELSE 'High'
END AS "CSAT Delta",
count(case_id)
FROM THIS_PROCESS
GROUP BY 1,2

Result:

The query returns the total number of cases in each CSAT Delta category (None, Low, Medium, and High) and
Country. The CSAT Delta category is determined by the delta between the maximum CSAT and minimum CSAT
value within the case.

SAP Signavio Analytics Language Guide


76 PUBLIC SAP Signavio Analytics Language
IF

The IF expression evaluates a single condition and returns one of two values accordingly.

• If the condition evaluates to true, the expression returns the first value.
• If the condition evaluates to false, the expression returns the second value.

You must provide both values. The values can be literals, column attributes or the results of other expressions,
such as additional IF expressions.

Syntax

IF(<condition>, <valueIfTrue>, <valueIfFalse>)

Parameters

Parameter Description

condition The condition to be evaluated.

valueIfTrue The value to be returned if the condition is met. This value


can be a literal, column attribute, result of an expression, or
additional IF expression.

valueIfFalse The value to be returned if the condition is not met. This


value can be a literal, column attribute, result of an expres-
sion, or additional IF expression.

Nested IF

IF expressions that contain additional IF expressions as value_if_true or value_if_false are called nested IF
expressions. Either or both of the possible return values, value_if_true and value_if_false, can be another IF
expression. The number of nested IF expressions is limited to 256.

Example - Simple IF

The following example returns a distinct list of cities along with an associated state. The IF expression is used
to compare the City to a literal value 'San Francisco'. If the City name matches the defined condition, the
state value is returned as 'California'. If the city does not match the defined condition, then the state value is
returned as 'Other'.

SELECT
DISTINCT "City",
IF("City" = 'San Francisco', 'California', 'Other') AS "State"
FROM THIS_PROCESS

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 77
Result:

Example - Nested IF

The following example returns a distinct list of cities along with corresponding states. The first IF expression
is used to compare the City to a literal value 'San Francisco'. If the city name matches the defined condition,
the state value is returned as 'California'. If the city does not match the defined condition, the next nested IF
expression is evaluated. If the state does not match the condition in the last IF expression, then the state value
is returned as 'Other'.

SELECT
DISTINCT "City",
IF(
"City" = 'San Francisco',
'California',
IF(
"City" = 'Miami',
'Florida',
IF("City" = 'Houston', 'Texas', 'Other')
)
) AS "State"
FROM THIS_PROCESS

SAP Signavio Analytics Language Guide


78 PUBLIC SAP Signavio Analytics Language
Result:

1.5.7 Expressions for NULL Values

Evaluate expressions involving NULL values.

IS NULL

Syntax

<expression> IS [NOT] NULL

Parameter Description

expression The expression to test for a NULL value.

IS NULL returns True if an expression evaluates to NULL. Otherwise it returns False.

Alternatively, IS NOT NULL returns True if an expression doesn't evalute to NULL. Otherwise it returns False.

Example - IS NULL

The following example returns the case IDs whose payment amount is null.

SELECT DISTINCT
"case_id" AS "Case ID",
"Shipment Number",
"Shipment Carrier"

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 79
FROM FLATTEN(THIS_PROCESS)
WHERE "SHIPMENT Number" IS NULL
LIMIT 10

Result:

Example - IS NOT NULL

The following example returns the case IDs where the payment amount is not null.

SELECT DISTINCT
"case_id" AS "Case ID",
"Shipment Number",
"Shipment Carrier"
FROM FLATTEN(THIS_PROCESS)
WHERE "SHIPMENT Number" IS NOT NULL
LIMIT 10

SAP Signavio Analytics Language Guide


80 PUBLIC SAP Signavio Analytics Language
Result:

1.5.8 Literal Expressions

A literal is a fixed value of a certain type. SIGNAL supports literals of several different types.

String Literal

String literals are always enclosed in single quotes. If a string literal contains one or more single quotes, these
single quotes must be followed by a single quote.

Example: O'Reilly -> 'O''Reilly'

Strings are case-sensitive. This means, for example, that the literals 'Smith' and 'smith' would be considered
different.

Number Literal

For decimal literals, the following conventions apply:

• 0-9
• 1.5 | .5
• 1e-10 | .5e+1000

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 81
DATE/TIMESTAMP Literal

With the DATE/TIMESTAMP literal function, you specify a timestamp as a literal.

Syntax:

DATE 'literal'
TIMESTAMP 'literal'

Parameter Description

literal The date or timestamp information, for ex-


ample DATE '2019-12-24' and TIMESTAMP
'2019-12-24T12:00:00' .

DURATION Literal

With the DURATION function you specify a duration literal which is parsed into a time interval.

Syntax:

DURATION 'literal'

Parameter Description

literal A numeric value to indicate the time and a string to indicate


the time unit, for example '3weeks', '4days', '3hours',
'5minutes', '6seconds', and '7milliseconds'.

Combined usage is possible, for example '1day1hour'.

For all duration strings, the singular and plural forms are
supported.

You can also follow the standard ISO-8601, for example


P1D6H30M.

Example:

SELECT COUNT(case_id)
FROM THIS_PROCESS
WHERE (SELECT LAST(EndTime) - FIRST(EndTime)) > DURATION '10days'

This query returns the number of cases in this process with more than 10 days between the start time and the
end time.

Boolean Literal

A Boolean literal can be one of two values:

SAP Signavio Analytics Language Guide


82 PUBLIC SAP Signavio Analytics Language
• TRUE
• FALSE

 Example

Assume that orders worth over 500 qualify for a discount. This query adds an attribute to the result set
stating whether a case qualifies.

SELECT
case_id,
"Order Amount",
IF("Order Amount" > 500, TRUE, FALSE) AS "Qualifies for Discount"
FROM THIS_PROCESS

1.6 Functions

Use functions in SIGNAL to carry out specific tasks and calculate values.

The following categories of function are available:

Aggregate Functions [page 84]


Use aggregate functions to reduce collections of values down to a single value.

Arithmetic Functions [page 103]


Use arithmetic functions to perform statistical calculations.

Conditional Functions [page 108]


Use conditional functions to define which operations to execute or which value to return based on a
condition.

Conversion Functions [page 111]


Use conversion functions to convert values from one data type to another.

Date Functions [page 122]


Use date functions to execute operations on date and time values.

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 83
String Functions [page 140]
Use string functions to manipulate strings in queries.

Window Functions [page 167]


Learn about window functions in SIGNAL, the process mining query language of SAP Signavio Process
Intelligence.

BUCKET Function [page 198]


Learn about the BUCKET() function in SIGNAL, the process mining query language of SAP Signavio
Process Intelligence.

Numeric Rounding Functions [page 201]


Learn about the numeric rounding functions in SIGNAL, the process mining query language of SAP
Signavio Process Intelligence.

1.6.1 Aggregate Functions

Use aggregate functions to reduce collections of values down to a single value.

Linear Regression Functions [page 85]


With the linear regression functions, you can calculate the relationship between two variables using the
least squares regression method, which is a standard approach for calculating a linear relationship. The
least squares regression line, also called the line of best fit, can be visualized as a straight line drawn
through a set of data points that represents the relationship between them.

AVG [page 88]


Calculates the average of a collection of numeric values. NULL values are ignored

BOOL_AND [page 89]


Returns true if the supplied expression evaluates to true for all input rows, otherwise it returns false.

BOOL_OR [page 90]


Returns true if the supplied expression evaluates to true for any input row, otherwise it returns false.

COUNT [page 91]


Counts the number of values in a specified column. NULL values aren't counted.

COUNT (DISTINCT) [page 92]


Counts the number of distinct values in a specified column. If NULL values are present, they are
excluded.

FIRST [page 93]


Returns the first element from a collection of values.

LAST [page 94]


Returns the last element from a collection of values.

MAX [page 95]


Finds the maximum value in a collection of values.

MEDIAN [page 96]


A shortcut for the PERCENTILE_CONT function with a fixed percentile of 0.5, that is the middle
number.

MIN [page 97]


Finds the minimum value in a collection of values.

SAP Signavio Analytics Language Guide


84 PUBLIC SAP Signavio Analytics Language
PERCENTILE_CONT [page 97]
Returns a percentile value based on the input column's continuous distribution. If no value lies at the
percentile, the linear interpolation between the closest two values is returned.

PERCENTILE_DISC [page 99]


Returns a percentile value based on the discrete distribution of values in a column. The returned value
has the smallest distance to the given percentile.

STDDEV [page 100]


Calculates the standard deviation for a collection of values.

SUM [page 102]


Calculates the sum of all values in a collection of numeric values. NULL values are ignored.

1.6.1.1 Linear Regression Functions

With the linear regression functions, you can calculate the relationship between two variables using the least
squares regression method, which is a standard approach for calculating a linear relationship. The least
squares regression line, also called the line of best fit, can be visualized as a straight line drawn through a set of
data points that represents the relationship between them.

For the regression line calculation, you need two parameters, slope and intercept. The slope and intercept
show how two variables are related according to an average rate of change, which works well with scatter plots
because scatter plots show two variables. The regression line is plotted on a scatter plot of the same data to
show the general data trend.

The purpose of the linear regression function is to find the relationship between the explanatory variable, X,
and the dependent variable, Y. It predicts the value of Y when the value of X is known.

Where to Use Linear Regression

• The primary purpose of the linear regression function is to facilitate the plotting of regression lines in
Correlation widget.
• You can also use the linear regression function within custom SQL statements to calculate trend or
regression values. This is useful for making predictions that extend beyond the provided data. For example,
suppose that order value is plotted against quantity and you want to know the value of an order size that is
10 times the maximum order size within your dataset.

Linear Regression Formula and Functions

A linear regression line has an equation of the form: Y = a + bX

X is the explanatory variable and Y is the dependent variable.

a = intercept (the value of Y when X = 0) and b = slope.

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 85
Following are the two functions implemented to support the linear regression:

• regr_slope(Y, X) function: slope of the least-squares-fit linear equation determined by the (X, Y) pairs
• regr_intercept(Y, X) function: Y-intercept of the least-squares-fit linear equation determined by the (X, Y)
pairs

The slope indicates the steepness of the regression line, whereas the intercept indicates its intersection with
the Y axis. The Y-intercept is the point at which the graph intersects the Y-axis. Based on the slope of each
X-axis unit, the subsequent point on the Y-axis is determined.

Syntax

REGR_INTERCEPT(<yAttribute>, <xAttribute>)
REGR_SLOPE(<yAttribute>, <xAttribute>)

Parameter Description Valid Types

yAttribute Y is the dependent variable and is plot- Number


ted along the Y axis of a scatterplot.

xAttribute X is the explanatory variable and is plot- Number


ted along the X axis of a scatterplot.

Returns: A Number, the intercept of the univariate linear regression line determined by the (X, Y) pairs.

Example 1

The following query correlates the order amount with order quantity and return values for intercept and slope.

SELECT
REGR_INTERCEPT("Order Amount" , "Order Quantity") as "Intercept",
REGR_SLOPE("Order Amount" , "Order Quantity") as "Slope"
FROM THIS_PROCESS

Result:

The query returns the following result.

Following is the scatter plot, generated using Correlation widget in a process. It shows the scatter plot and
regression line for order amount plotted against order quantity.

SAP Signavio Analytics Language Guide


86 PUBLIC SAP Signavio Analytics Language
Example 2

The following query calculates the order value along the regression line relative to an order size that isn't
included in your data set.

SELECT 300 as "Quantity","intercept" + 300 * "slope" as "Amount"


FROM
(
SELECT
REGR_INTERCEPT("Order Amount" , "Order Quantity") as "intercept",
REGR_SLOPE("Order Amount" , "Order Quantity") as "slope"
FROM THIS_PROCESS
) as sub

Result:

The query returns the following result.

Example 3

The following query calculates the order value along the regression line relative to an order size that isn't
included in your data set and grouped by City.

SELECT "City",

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 87
300 as "Quantity",
"intercept" + 300 * "slope" as "Amount"
FROM
(
SELECT "City",
REGR_INTERCEPT("Order Amount" , "Order Quantity") as "intercept",
REGR_SLOPE("Order Amount" , "Order Quantity") as "slope"
FROM THIS_PROCESS
GROUP BY 1
) as sub

Result:

The query returns the following result.

1.6.1.2 AVG
Calculates the average of a collection of numeric values. NULL values are ignored

Syntax

AVG(<expression>)

Parameter Description Valid Types

expression The column of values to be averaged. Number, Timestamp, Duration

Returns: The average as a Number, Timestamp or Duration. The return type matches the type of the
expression parameter.

SAP Signavio Analytics Language Guide


88 PUBLIC SAP Signavio Analytics Language
AVG can also be used as a window function:

AVG(<expression>) OVER (
[ PARTITION BY [, <partitionExpression>, ...] ]
[ ORDER BY <orderExpression> [ { ASC | DESC } ] [, <orderExpression>, ...] [
<windowFrame> ] ]
)

For more details about this syntax, refer to the Window Functions overview.

Example

This query returns the average order amount of all cases.

SELECT AVG("Order Amount")


FROM THIS_PROCESS

Related Information

Window Functions [page 167]

1.6.1.3 BOOL_AND

Returns true if the supplied expression evaluates to true for all input rows, otherwise it returns false.

Syntax

BOOL_AND(<expression>)

Parameter Description Valid Types

expression An expression applied to a collection of Boolean


rows.

Returns: A Boolean. Result is true if all input rows evaluate to true for the supplied expression, otherwise false.

BOOL_AND can also be used as a window function:

BOOL_AND(<expression>) OVER (
[ PARTITION BY [, <partitionExpression>, ...] ]
[ ORDER BY <orderExpression> [ { ASC | DESC } ] [, <orderExpression>, ...] [
<windowFrame> ] ]
)

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 89
For more details about this syntax, refer to the Window Functions overview.

Example

This query returns true if all rows record an approval performed by a manager.

SELECT
(SELECT BOOL_AND(event_name = 'Approve' AND performer = 'Manager'))
FROM THIS_PROCESS

Related Information

Window Functions [page 167]

1.6.1.4 BOOL_OR

Returns true if the supplied expression evaluates to true for any input row, otherwise it returns false.

Syntax

BOOL_OR(<expression>)

Parameter Description Valid Types

expression An expression applied to a collection of Boolean


rows.

Returns: A Boolean. Result is true if any input row evaluates to true for the supplied expression, otherwise false.

BOOL_OR can also be used as a window function:

BOOL_OR(<expression>) OVER (
[ PARTITION BY [, <partitionExpression>, ...] ]
[ ORDER BY <orderExpression> [ { ASC | DESC } ] [, <orderExpression>, ...] [
<windowFrame> ] ]
)

For more details about this syntax, refer to the Window Functions overview.

SAP Signavio Analytics Language Guide


90 PUBLIC SAP Signavio Analytics Language
Example

This query returns true if any row records an approval performed by a manager.

SELECT
(SELECT BOOL_OR(event_name = 'Approve' AND performer = 'Manager'))
FROM THIS_PROCESS

Related Information

Window Functions [page 167]

1.6.1.5 COUNT

Counts the number of values in a specified column. NULL values aren't counted.

Syntax

COUNT(<expression>)

Parameter Description Valid Types

expression The column whose values are to be Any


counted.

Returns: The number of values in the provided collection of values.

COUNT can also be used as a window function:

COUNT(<expression>) OVER (
[ PARTITION BY [, <partitionExpression>, ...] ]
[ ORDER BY <orderExpression> [ { ASC | DESC } ] [, <orderExpression>, ...] [
<windowFrame> ] ]
)

For more details about this syntax, refer to the Window Functions overview.

Example

This query returns the number of cases.

SELECT COUNT(case_id)

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 91
FROM THIS_PROCESS

Related Information

Window Functions [page 167]

1.6.1.6 COUNT (DISTINCT)

Counts the number of distinct values in a specified column. If NULL values are present, they are excluded.

In the case of counting event-level columns, since event-level columns are lists, this function counts the
number of distinct lists.

Syntax

COUNT(DISTINCT <expression>)

Parameter Description Valid Types

expression The column whose distinct values are Number, Text, Timestamp, List (i.e.
to be counted. event-level column)

Returns: The number of distinct values in the provided collection of values.

Example 1 (Case-level)

This query returns the number of distinct cities.

SELECT COUNT(DISTINCT city)


FROM THIS_PROCESS

Example 2 (Event-level)

This query counts the number of distinct event sequences per case. Each distinct sequence represents a
process variant, therefore this query returns the number of process variants.

SELECT COUNT(DISTINCT event_name)


FROM THIS_PROCESS

SAP Signavio Analytics Language Guide


92 PUBLIC SAP Signavio Analytics Language
1.6.1.7 FIRST

Returns the first element from a collection of values.

Syntax

FIRST(<expression>)

Parameter Description Valid Types

expression The collection of values from which the Number, Timestamp, Duration, Text,
first is chosen. Boolean

Returns: The first value as a Number, Timestamp, Duration, Text or Boolean. The return type matches the type
of the expression parameter.

FIRST can also be used as a window function:

FIRST(<expression>) OVER (
[ PARTITION BY [, <partitionExpression>, ...] ]
[ ORDER BY <orderExpression> [ { ASC | DESC } ] [, <orderExpression>, ...] [
<windowFrame> ] ]
)

For more details about this syntax, refer to the Window Functions overview.

Example

This query returns the name of the first event in this process.

SELECT
(SELECT FIRST(event_name))
FROM THIS_PROCESS

Related Information

Window Functions [page 167]

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 93
1.6.1.8 LAST

Returns the last element from a collection of values.

Syntax

LAST(<expression>)

Parameter Description Valid Types

expression The collection of values from which the Number, Timestamp, Duration, Text,
last is chosen. Boolean

Returns: The last value as a Number, Timestamp, Duration, Text or Boolean. The return type matches the type
of the expression parameter.

LAST can also be used as a window function:

LAST(<expression>) OVER (
[ PARTITION BY [, <partitionExpression>, ...] ]
[ ORDER BY <orderExpression> [ { ASC | DESC } ] [, <orderExpression>, ...] [
<windowFrame> ] ]
)

For more details about this syntax, refer to the Window Functions overview.

Example

This query returns the name of the last event in this process.

SELECT
(SELECT LAST(event_name))
FROM THIS_PROCESS

Related Information

Window Functions [page 167]

SAP Signavio Analytics Language Guide


94 PUBLIC SAP Signavio Analytics Language
1.6.1.9 MAX

Finds the maximum value in a collection of values.

Syntax

MAX(<expression>)

Parameter Description Valid Types

expression The collection from which the maxi- Number, Timestamp, Duration
mum value is chosen.

Returns: The maximum value as a Number, Timestamp or Duration. The return type matches the type of the
expression parameter.

MAX can also be used as a window function:

MAX(<expression>) OVER (
[ PARTITION BY [, <partitionExpression>, ...] ]
[ ORDER BY <orderExpression> [ { ASC | DESC } ] [, <orderExpression>, ...] [
<windowFrame> ] ]
)

For more details about this syntax, refer to the Window Functions overview.

Example

This query returns the largest discount.

SELECT MAX(discount)
FROM THIS_PROCESS

Related Information

Window Functions [page 167]

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 95
1.6.1.10 MEDIAN

A shortcut for the PERCENTILE_CONT function with a fixed percentile of 0.5, that is the middle number.

Syntax

MEDIAN(<expression>)

Parameter Description Valid Types

expression The column of which you want to deter- Number, Timestamp, Duration
mine the value that separates the lower
from the upper half.

Returns: The median value as a Number, Timestamp or Duration. The return type matches the type of the
column_name parameter.

Example

This query calculates the median of a set of numerical values.

1 65

2 72

3 81

4 95

5 112

6 128

SELECT MEDIAN(A)
FROM THIS_PROCESS

The query determines in a first step the value position = 3. Because the sorted list has an even number of
items, this query calculates the arithmetic mean, that is (81 + 95)/2 = 88.

SAP Signavio Analytics Language Guide


96 PUBLIC SAP Signavio Analytics Language
1.6.1.11 MIN

Finds the minimum value in a collection of values.

Syntax

MIN(<expression>)

Parameter Description Valid Types

expression The collection from which the minimum Number, Timestamp, Duration
value is chosen.

Returns: The minimum value as a Number, Timestamp or Duration. The return type matches the type of the
expression parameter.

MIN can also be used as a window function:

MIN(<expression>) OVER (
[ PARTITION BY [, <partitionExpression>, ...] ]
[ ORDER BY <orderExpression> [ { ASC | DESC } ] [, <orderExpression>, ...] [
<windowFrame> ] ]
)

For more details about this syntax, refer to the Window Functions overview.

Example

This query returns the smallest discount.

SELECT MIN(discount)
FROM THIS_PROCESS

Related Information

Window Functions [page 167]

1.6.1.12 PERCENTILE_CONT

Returns a percentile value based on the input column's continuous distribution. If no value lies at the
percentile, the linear interpolation between the closest two values is returned.

NULL values are ignored. If all values are NULL, this function returns NULL.

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 97
Syntax

PERCENTILE_CONT(<p>) WITHIN GROUP(ORDER BY <expression>)

Parameter Description Valid Types

p The percentile of the value that you Number (literal)


want to find. For example, specify 0.8
if you want to find the 80th percentile.
Must be between 0.0 and 1.0

expression The column for which you want to de- Number, Timestamp, Duration
termine the value that separates the
lower from the upper percentile for the
given percentile rank.

Returns: The calculated continuous percentile as a Number, Timestamp or Duration. The return type matches
the type of the expression parameter.

Example

1 65

2 72

3 81

4 95

5 112

6 128

SELECT
PERCENTILE_CONT(0.25) WITHIN GROUP (ORDER BY A)
FROM THIS_PROCESS

This query determines in a first step the value position = 1.5. Because it's a fraction, the result value is the
average of position 1 and 2 = 68.5. Values below 68.5 are in the lower percentile, values above 68.5 are in the
upper percentile.

SELECT
PERCENTILE_CONT(0.75) WITHIN GROUP (ORDER BY A)
FROM THIS_PROCESS

For p = 0.75, the value position = 4.5. The result is the average of position 4 and 5, that is 103.5.

SAP Signavio Analytics Language Guide


98 PUBLIC SAP Signavio Analytics Language
Related Information

PERCENTILE_DISC [page 99]

1.6.1.13 PERCENTILE_DISC

Returns a percentile value based on the discrete distribution of values in a column. The returned value has the
smallest distance to the given percentile.

NULL values are ignored. If all values are NULL, this function returns NULL.

Syntax

PERCENTILE_DISC(<p>) WITHIN GROUP(ORDER BY <expression>)

Parameter Description Valid Types

p The percentile of the value that you Number (literal)


want to find. For example, specify 0.8
if you want to find the 80th percentile.
Must be between 0.0 and 1.0

expression The column for which you want to de- Number, Timestamp, Duration
termine the value that separates the
lower from the upper percentile for the
given percentile rank.

Returns: The calculated discrete percentile. The return type matches the type of the expression parameter.

Example

1 65

2 72

3 81

4 95

5 112

6 128

SELECT
PERCENTILE_DISC(0.25) WITHIN GROUP (ORDER BY A)

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 99
FROM THIS_PROCESS

This query determines the value position = 1.5. Because it's a fraction, the value at the next higher position is
returned, that is 72.

Related Information

PERCENTILE_CONT [page 97]

1.6.1.14 STDDEV

Calculates the standard deviation for a collection of values.

The standard deviation describes the average deviation of all measured values from the mean value. A low
standard deviation indicates that the values tend to be close to the mean value. A high standard deviation
indicates that the values are spread out over a wide range.

Syntax

STDDEV(<expression>)

Parameter Description Valid Types

expression The collection of values for which you Number, Timestamp, Duration
want to determine the standard devia-
tion.

Returns: The standard deviation as a Number, Timestamp, or Duration. The return type matches the type of
the expression parameter.

STDDEV can also be used as a window function:

STDDEV(<expression>) OVER (
[ PARTITION BY [, <partitionExpression>, ...] ]
[ ORDER BY <orderExpression> [ { ASC | DESC } ] [, <orderExpression>, ...] [
<windowFrame> ] ]
)

For more details about this syntax, refer to the Window Functions overview.

SAP Signavio Analytics Language Guide


100 PUBLIC SAP Signavio Analytics Language
Example 1

This query returns the standard deviation of all order amounts.

SELECT
MIN("Order Amount") AS "Min",
MAX("Order Amount") AS "Max",
AVG("Order Amount") AS "Avg",
STDDEV("Order Amount") AS "StdDev"
FROM THIS_PROCESS

Output:

Example 2

This query shows how the cycle time of a process changes week-to-week. Specifically, it calculates both the
average and the standard deviation of the cycle time on a weekly basis.

To smooth out short-term fluctuations in the data, it uses windowed versions of the average (AVG) and
standard deviation (STDDEV) functions. These versions calculate a moving average and moving standard
deviation for the weekly mean cycle time respectively.

In the nested query, sq1, all cases are clustered together by week. The mean cycle time within each cluster is
calculated.

The outer query applies the windowed AVG and STDDEV functions to the weekly mean cycle time. In both cases,
the window includes the three weeks preceding and the three weeks following the current week.

SELECT
"Week",
"Avg Cycle Time",
AVG("Avg Cycle Time") OVER (ROWS BETWEEN 3 PRECEDING AND 3 FOLLOWING) as
mean,
STDDEV("Avg Cycle Time") OVER (ROWS BETWEEN 3 PRECEDING AND 3 FOLLOWING) as
std
FROM
(
SELECT
DATE_TRUNC('WEEK', (SELECT LAST (END_TIME))) AS "Week",
AVG((SELECT LAST(end_time) - FIRST(end_time))) AS "Avg Cycle Time"
FROM THIS_PROCESS
ORDER BY 1 ASC NULLS FIRST
FILL timeseries('WEEK')
) as sq1

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 101
Related Information

Window Functions [page 167]

1.6.1.15 SUM

Calculates the sum of all values in a collection of numeric values. NULL values are ignored.

Syntax

SUM(<expression>)

Parameter Description Valid Types

expression The collection of values to be summed. Number, Duration

Returns: The sum as a Number or Duration. The return type matches the type of the expression parameter.

SUM can also be used as a window function:

SUM(<expression>) OVER (
[ PARTITION BY [, <partitionExpression>, ...] ]
[ ORDER BY <orderExpression> [ { ASC | DESC } ] [, <orderExpression>, ...] [
<windowFrame> ] ]

SAP Signavio Analytics Language Guide


102 PUBLIC SAP Signavio Analytics Language
)

For more details about this syntax, refer to the Window Functions overview.

Example

This query returns the total order amount in Boston.

SELECT SUM("ORDER AMOUNT")


FROM THIS_PROCESS
WHERE("City" = 'Boston')

Related Information

Window Functions [page 167]

1.6.2 Arithmetic Functions

Use arithmetic functions to perform statistical calculations.

ABS [page 104]


Returns the absolute value of an expression. For an expression, x, the non-negative value of x is
returned regardless of its sign.

LOG [page 105]


Calculates the exponent of the equation x = b ^ (y) -> log (b,x) = y of a numeric expression.

POW [page 106]


Raises a base value to an exponent power.

SIGN [page 107]


Returns the sign of a real number of a numeric expression.

SQRT [page 108]


Calculates the square root of a numeric expression

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 103
1.6.2.1 ABS

Returns the absolute value of an expression. For an expression, x, the non-negative value of x is returned
regardless of its sign.

Syntax

ABS(<expression>)

Parameter Description Valid Types

expression The value for which you want to calcu- Number


late the absolute value.

Returns: The absolute value of the argument as a Number.

Example 1

This example shows ABS applied to simple values.

SELECT ABS(-3) AS Negative, ABS(4) AS Positive


FROM THIS_PROCESS

The resulting table displays the absolute values of the two values:

Example 2

This example finds all changes to order quantities. Since changes can be negative or positive, this query
returns only the magnitude of each change.

SELECT
case_id,
"Order Quantity Changed" AS Change,
ABS("Order Quantity Changed") AS AbsChange
FROM FLATTEN(THIS_PROCESS)
WHERE event_name = 'Change Order Quantity'

Even where order sizes were reduced, those changes can be presented as absolute values.

SAP Signavio Analytics Language Guide


104 PUBLIC SAP Signavio Analytics Language
1.6.2.2 LOG

Calculates the exponent of the equation x = b ^ (y) -> log (b,x) = y of a numeric expression.

Syntax

LOG(<expression>, <base>)

Parameter Description Valid Types

expression The value for which the logarithm is cal- Number


culated.

base The base to which the logarithm is cal- Number (literal)


culated.

Returns: A Number, the logarithm of the value calculated to the specified base.

Example

SELECT
LOG(10, 1000),
LOG(3, 27),
LOG(2, 8)
FROM THIS_PROCESS

The table displays the results of the three calculations. In each case, the result is 3 (specifically, 2 ^ 3 = 8, 3 ^ 3
= 27, and 2 ^ 3 = 8).

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 105
1.6.2.3 POW
Raises a base value to an exponent power.

Syntax

POW(<base>, <exponent>)

Parameter Description Valid Types

base The value to be raised. Number

exponent The exponent power to raise by. Number (literal)

Returns: A number, the base value raised to the exponent value.

Example

SELECT
POW(9, 2),
POW(9, 0.5),
POW(9, 0),
POW(9, 1)
FROM THIS_PROCESS

The table displays the results of the four calculations:

SAP Signavio Analytics Language Guide


106 PUBLIC SAP Signavio Analytics Language
1.6.2.4 SIGN

Returns the sign of a real number of a numeric expression.

For a real number x, return:

• -1 if x < 0
• 0 if x = 0
• 1 if x > 0

Syntax

SIGN(<expression>)

Parameter Description Valid Types

expression The value for which you want to extract Number


the sign.

Returns: A Number denoting the sign of the argument.

Example

SELECT
SIGN(10) AS Positive,
SIGN(0) AS Zero,
SIGN(-8) AS Negative
FROM THIS_PROCESS

The resulting table displays the signs of the three numeric expressions:

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 107
1.6.2.5 SQRT

Calculates the square root of a numeric expression

Syntax

SQRT(<expression>)

Parameter Description Valid Types

expression The value for which you want to calcu- Number


late the square root.

Returns: The square root of the argument as a Number.

Example 1

This query calculates the square root from the given argument. For expression = 9, the result is 3.

SELECT SQRT(9)
FROM THIS_PROCESS

Example 2

This query calculates the square root from the order amounts.

SELECT SQRT("Order Amount in EUR")


FROM THIS_PROCESS

1.6.3 Conditional Functions

Use conditional functions to define which operations to execute or which value to return based on a condition.

COALESCE [page 109]


Accepts an arbitrary number of arguments and returns the first argument that isn't NULL.

SAP Signavio Analytics Language Guide


108 PUBLIC SAP Signavio Analytics Language
1.6.3.1 COALESCE

Accepts an arbitrary number of arguments and returns the first argument that isn't NULL.

Syntax

COALESCE(<expression> [, <expression> ...] )

Parameter Description Valid Types

expression Any combination of values, functions, Any


or operators that evaluate to a value.
 Note
A minimum of one expression must be
While this function accepts argu-
provided.
ments of any type, all expressions
must evaluate to the same type
within the same invocation of the
function.

Returns: The value of the first non-NULL expression. If all arguments are NULL, this function returns NULL.

Example 1

Let's assume a process containing the following data (THIS_PROCESS):

case_id City Country Continent

1 Berlin Germany Europe

2 Singapore null Asia

3 null null Antarctica

4 null null null

The following query returns the most precise location available in each case:

SELECT COALESCE(City, Country, Continent) AS "Location"


FROM THIS_PROCESS

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 109
Output:

Example 2

A useful application of COALESCE is providing a fallback in case an expression evaluates to NULL. The fallback
should be a literal value supplied as the last argument to the function.

Assuming the same process data as in Example 1, the following query displays the location in each case, but
has a fallback value of "Unknown" in cases where the city is NULL.

SELECT COALESCE(City, 'Unknown') AS "Location" FROM THIS_PROCESS

Output:

SAP Signavio Analytics Language Guide


110 PUBLIC SAP Signavio Analytics Language
1.6.4 Conversion Functions

Use conversion functions to convert values from one data type to another.

DURATION_FROM_DAYS [page 111]


Converts a number of days into a Duration.

DURATION_FROM_MILLISECONDS [page 112]


Converts a number of milliseconds into a Duration.

DURATION_TO_DAYS [page 113]


Converts a Duration value into the equivalent number of days.

DURATION_TO_MILLISECONDS [page 114]


Converts a Duration value into the equivalent number of milliseconds.

TO_NUMBER [page 115]


Converts an expression to a number.

TO_STRING [page 116]


Converts a number or timestamp to a string.

TO_TIMESTAMP [page 118]


Converts a string to a timestamp.

Timestamp Pattern [page 121]


Timestamp patterns specify a format for showing date and time values.

Related Information

Data types [page 5]

1.6.4.1 DURATION_FROM_DAYS

Converts a number of days into a Duration.

Syntax

DURATION_FROM_DAYS(<expression>)

Parameter Description Valid Types

expression Number of days. Number

Returns: A Duration, the length of time represented by the original number of days.

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 111
Example

This query demonstrates converting a number of days to a Duration.

SELECT DURATION_FROM_DAYS(3.5) AS "3 and a half days"


FROM THIS_PROCESS

Output:

1.6.4.2 DURATION_FROM_MILLISECONDS
Converts a number of milliseconds into a Duration.

Syntax

DURATION_FROM_MILLISECONDS(<expression>)

Parameter Description Valid Types

expression Number of milliseconds. Number

Returns: A Duration, the length of time represented by the original number of milliseconds.

Example

This query demonstrates two instances of converting a number of milliseconds to a Duration. In both cases, the
argument has a value of 720,000 and therefore returns a duration of 12 minutes.

SELECT
DURATION_FROM_MILLISECONDS(720000) AS "Duration 1",
DURATION_FROM_MILLISECONDS(12*60*1000) AS "Duration 2"
FROM THIS_PROCESS

Output:

SAP Signavio Analytics Language Guide


112 PUBLIC SAP Signavio Analytics Language
1.6.4.3 DURATION_TO_DAYS

Converts a Duration value into the equivalent number of days.

Syntax

DURATION_TO_DAYS(<expression>)

Parameter Description Valid Types

expression The duration to be converted. Duration

Returns: A Number, the days in the original duration. The value is a decimal and so may include fractions of a
day.

Example

This query calculates a case's duration by subtracting the last event's timestamp from the first event's
timestamp, which yields a duration. This duration becomes an argument in a call to DURATION_TO_DAYS.

SELECT case_id,
(SELECT FIRST(end_time)) AS "Start",
(SELECT LAST(end_time)) AS "End",
(SELECT LAST(end_time)) - (SELECT FIRST(end_time)) AS "Duration",
DURATION_TO_DAYS( (SELECT LAST(end_time)) - (SELECT FIRST(end_time)) ) AS
"Duration in days"
FROM THIS_PROCESS

Output:

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 113
Related Information

DURATION Literal [page 82]

1.6.4.4 DURATION_TO_MILLISECONDS
Converts a Duration value into the equivalent number of milliseconds.

Syntax

DURATION_TO_MILLISECONDS(<expression>)

Parameter Description Valid Types

expression The duration to be converted. Duration

Returns: A Number, the milliseconds in the original duration.

Example

This query calculates a case's duration by subtracting the last event's timestamp from the first
event's timestamps, which yields a duration. This duration becomes an argument in two calls to
DURATION_TO_MILLISECONDS. The first call returns the number of milliseconds. The second call does the
same but is followed by a conversion of the millisecond value into minutes.

SELECT case_id,
(SELECT FIRST(end_time)) AS "Start",
(SELECT LAST(end_time)) AS "End",
(SELECT LAST(end_time)) - (SELECT FIRST(end_time)) AS "Duration",
DURATION_TO_MILLISECONDS( (SELECT LAST(end_time)) - (SELECT
FIRST(end_time)) ) AS "In ms",
DURATION_TO_MILLISECONDS( (SELECT LAST(end_time)) - (SELECT
FIRST(end_time)) ) / (1000*60) AS "In min"
FROM THIS_PROCESS

Output:

SAP Signavio Analytics Language Guide


114 PUBLIC SAP Signavio Analytics Language
1.6.4.5 TO_NUMBER

Converts an expression to a number.

 Caution

For very large data sets, this function may require excessive CPU activity, causing long query execution
times.

For more information, refer to Performance [page 209].

Syntax

TO_NUMBER(<expression>)

Parameter Description Valid Types

expression Evaluates to a value to be converted String


into a number.

Returns: A numeric value, if the value of the string expression can be converted to a number. If expression
can't be converted, then this function returns NULL.

Formatting

The expression argument must strictly follow a numeric format. The only accepted non-numeric character is
a decimal point – commas aren't supported for separating the integer and fractional parts of a number.

Extraneous characters, such as currency symbols or thousands separators, prevent the number from being
converted.

 Tip

Consider using the SUBSTRING_BEFORE or SUBSTRING_AFTER functions to remove extraneous


characters from a string before conversion. For example, if your "Order Amount" column records
values with a leading currency symbol (like '$123.45'), the value could be converted like so:
TO_NUMBER(SUBSTRING_AFTER("Order Amount", '$')).

This function doesn't support formatting the output.

Example 1

Let's assume we have the following process data (THIS_PROCESS). The days and order amounts are stored as
strings, but aren't formatted consistently.

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 115
case_id Day Order Amount

1 1 100

2 2nd 1000

3 3 1,500

4 null $300

5 five 99.45

The following query converts those values into numbers where possible. In the case of the Order Amount, the
query also performs arithmetic on the resulting value.

SELECT
TO_NUMBER("Day") AS "Day",
TO_NUMBER("Order Amount") * 0.9 AS "Discounted Amount"
FROM THIS_PROCESS

Output:

1.6.4.6 TO_STRING

Converts a number or timestamp to a string.

When converting a timestamp to a string, you can optionally provide its format using a timestamp pattern. If a
pattern isn't provided, the timestamp value is parsed according to RFC 3339 .

Syntax

TO_STRING(<expression> [, <pattern>] )

SAP Signavio Analytics Language Guide


116 PUBLIC SAP Signavio Analytics Language
Parameter Description Valid Types

expression Evaluates to a value to be converted to Number, Timestamp


a string.

pattern Optional. String literal

• If expression is a number, pro-


viding pattern leads to an error.
• If expression is a timestamp,
pattern defines the timestamp
format.

 Note
This pattern follows a defined syn-
tax. Refer to the Timestamp Pat-
tern topic.

Returns: The value of expression as a string. If expression evaluates to NULL, this function returns NULL.

Example 1

The query in this example shows conversion of numeric and timestamp values.

The order amount is a numeric value. To display the amount with a currency symbol, the value must first be
converted to a string before it's concatenated to the symbol.

The date selected is that of the start event in each case. It's converted to a string without providing a
timestamp pattern, meaning it's displayed using the default pattern.

SELECT
case_id,
"Order Amount",
CONCAT('$', TO_STRING("Order Amount")) AS "Order Amount ($)",
(SELECT FIRST(end_time)) AS "Creation Date",
TO_STRING((SELECT FIRST(end_time))) AS "Date as String"
FROM THIS_PROCESS

Output:

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 117
Example 2

The following query demonstrates how the timestamp pattern can be used to format the output of a
timestamp when it's converted to a string.

SELECT
case_id,
(SELECT FIRST(end_time)) AS "Creation Date",
TO_STRING((SELECT FIRST(end_time)), 'DD-MM-YYYY') AS "Date",
TO_STRING((SELECT FIRST(end_time)), 'HH:mm:ss.SSS') AS "24hr Time w/ ms",
TO_STRING((SELECT FIRST(end_time)), 'hh:mm aa') AS "12hr Time"
FROM THIS_PROCESS

Output:

Related Information

Timestamp Pattern [page 121]

1.6.4.7 TO_TIMESTAMP

Converts a string to a timestamp.

You can optionally provide the format of the timestamp using a timestamp pattern. If a pattern isn't provided,
the timestamp value is parsed according to RFC 3339.

 Caution

For very large data sets, this function may require excessive CPU activity when including a timestamp
pattern, causing long query execution times.

For more information, refer to Performance [page 209].

SAP Signavio Analytics Language Guide


118 PUBLIC SAP Signavio Analytics Language
Syntax

TO_TIMESTAMP(<expression> [, <pattern>] )

Parameter Description Valid Types

expression Evaluates to a value to be converted String


into a timestamp value.

pattern Optional. Defines the timestamp for- String literal

mat.

 Note
This pattern follows a defined syn-
tax. Refer to the Timestamp Pat-
tern topic.

Returns: The expression as a timestamp. If expression evaluates to NULL, this function returns NULL.

Example 1

Let's assume we have the following process data (THIS_PROCESS), where the timestamp and date information
is stored as strings:

case_id timestamp_string date_string

1 1970-01-01T00:00:00.000Z 01/01/1970

2 1970-01-01T00:00:01.000Z 01/01/1970

3 null null

4 2023-09-13T18:55:30.000+02:00 13/09/2023

5 2023-09-13T16:55:30.000Z 13/09/2023

The following query converts the strings into timestamp values.

SELECT
case_id,
TO_TIMESTAMP(timestamp_string) AS "Timestamp Value",
TO_TIMESTAMP(date_string, 'DD/MM/YYYY') AS "Date Value"
FROM THIS_PROCESS

Output:

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 119
Note that the "Timestamp Value" in cases 1 and 2 are stored internally as 0 and 1000 respectively (since a
timestamp is the number of milliseconds since midnight on Jan 1, 1970).

Example 2

Continuing with the data from the previous example, this query demonstrates how TO_STRING and
TO_TIMESTAMP are inverses of one another.

The following query returns the original timestamp string value after conversion to and from a timestamp, but
in the timezone UTC+0.

SELECT
case_id,
TO_STRING(TO_TIMESTAMP(timestamp_string)) AS "Original Timestamp"
FROM THIS_PROCESS

Output:

SAP Signavio Analytics Language Guide


120 PUBLIC SAP Signavio Analytics Language
Related Information

RFC 3339
Timestamp Pattern [page 121]
TO_STRING [page 116]

1.6.4.8 Timestamp Pattern

Timestamp patterns specify a format for showing date and time values.

A timestamp pattern is a string used when converting date and time values to strings. Each character in the
pattern specifies which element of a timestamp features in the output and how it appears.

The following table shows all available pattern characters.

Pattern Character Description

YYYY Year (0000-9999)

YY Two-digit year, that is, year modulo 100 (00-99)

 Note
This pattern character is supported only in the
TO_STRING function.

MM Month, padded with zero (01-12)

M Month (1-12)

DD Day of month, padded with zero (01-31)

D Day of month (1-31)

HH Hour, 24h clock, padded with zero (00-23)

H Hour, 24h clock (0-23)

hh Hour, 12h clock, padded with zero (01-12)

h Hour, 12h clock (1-12)

aa am/pm (lowercase)

AA AM/PM (uppercase)

mm Minute, padded with zero (00-59)

m Minute (0-59)

ss Second, padded with zero (00-60)

s Second (0-60)

SSS Fractional seconds with millisecond precision (000-999)

SSSSSS Fractional seconds with microsecond precision


(000000-999999)

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 121
Pattern Character Description

SSSSSSSSS Fractional seconds with nanosecond precision


(000000000-999999999)

Z Timezone offset, hours only (-24-+24)

ZZ Timezone offset, hours, and minutes (-2400-+2459)

ZZZ Timezone offset, hours, and minutes separated by colon


(-24:00-+24:59)

T Literal T

Any other letter Reserved for future extensions

[, ], {, }, %, # Reserved for future extensions

'' Literal single quote (')

'string' Literal string

Any other character Printed literally

Remarks

Some pattern characters behave more leniently:

• Both padded and unpadded inputs are accepted. For example, the pattern M/D/YYYY also parses
01/01/1970 and MM/DD/YYYY also parses 1/1/1970.
• Timezones are parsed in any supported format. Z/ZZ/ZZZ parses any of the following timezone offsets:
Z/+00/+0000/ +00:00

The patterns for fractional sections (SSS / SSSSSS / SSSSSSSSS) expect the exact number of fractional
digits:

• For example, the pattern .SSS doesn't accept an input of .1.

When the optional pattern parameter is omitted, the following applies:

• A default pattern is used, namely:YYYY-MM-DDTHH:mm:ss.SSSZZZ.


• The function TO_TIMESTAMP also accepts a space instead of the literal T.
• The function TO_STRING formats the timezone as a literal Z. All timestamps are stored using UTC
internally.

1.6.5 Date Functions

Use date functions to execute operations on date and time values.

 Note

The default timestamp format in SIGNAL is dd/mm/yyyy.

SAP Signavio Analytics Language Guide


122 PUBLIC SAP Signavio Analytics Language
DATE_ADD [page 123]
Adds a given number of date or time units to a timestamp.

DATE_DIFF [page 127]


Returns the period between two timestamps as a number of date or time units.

DATE_PART [page 131]


Extracts part of a date from a given timestamp.

DATE_TRUNC [page 132]


Truncates the displayed precision level of timestamps.

DURATION_BETWEEN [page 134]


Calculates the working time between two timestamps.

DURATION_FROM_DAYS [page 136]


Converts a number of days into a Duration.

DURATION_FROM_MILLISECONDS [page 137]


Converts a number of milliseconds into a Duration.

DURATION_TO_DAYS [page 137]


Converts a Duration value into the equivalent number of days.

DURATION_TO_MILLISECONDS [page 139]


Converts a Duration value into the equivalent number of milliseconds.

NOW [page 140]


Returns the current UTC timestamp.

1.6.5.1 DATE_ADD

Adds a given number of date or time units to a timestamp.

Syntax

DATE_ADD(<unit>, <number>, <timestamp>)

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 123
Parameter Description Valid Types

unit The date or time unit to be added. String literal

The following units are supported:

• 'year'
• 'quarter'
• 'month'
• 'week'
• 'day'
• 'hour'
• 'minute'
• 'second'
• 'millisecond'

number An expression determining the number Number

of units to add to timestamp.

This parameter accepts negative val-


ues, allowing you to subtract units.

 Note
Fractional parts of this value are ig-
nored.

timestamp A timestamp expression. Timestamp

Returns: A new timestamp, the result of adding the specified number of units to the timestamp parameter. If
number or timestamp is NULL, then this function returns NULL.

Handling Calendar Time

The function doesn't take calendar quarters or weeks into account:

• Adding a year is equivalent to adding 12 months.


• Adding a quarter is equivalent to adding 3 months.
• Adding a week is equivalent to adding 7 days.

Months are handled specially. Adding N months increases the month part of the timestamp by N, wrapping the
value around as necessary if the year boundary is passed. If the day part of the resulting timestamp would be
greater than the number of days in the month, then the day value becomes the last day of the month.

For example, simply adding a month to '2023-01-31' would yield '2023-02-31', an invalid date. Therefore,
DATE_ADD('month', 1, DATE '2023-01-31') returns '2023-02-28'

The special handling of months means that this function isn't associative, meaning that chaining together
calls to DATE_ADD can have different results depending on the order of the calls. Refer to Example 3 for a
demonstration.

SAP Signavio Analytics Language Guide


124 PUBLIC SAP Signavio Analytics Language
Example 1

Let's assume we have the following data set (THIS_PROCESS):

Running the query

SELECT start_date,
DATE_ADD('year', 1, start_date) AS "+ 1 year",
DATE_ADD('quarter', 1, start_date) AS "+ 1 quarter",
DATE_ADD('month', 1, start_date) AS "+1 month",
DATE_ADD('day', 1, start_date) AS "+1 day",
DATE_ADD('hour', 1, start_date) AS "+1 hour"
FROM THIS_PROCESS

produces the following output:

Example 2

Using the process data from the previous example, the following query demonstrates subtracting time units
from a timestamp:

SELECT start_date,
DATE_ADD('year', -2, start_date) AS "-2 years",
DATE_ADD('quarter', -3, start_date) AS "-3 quarters",
DATE_ADD('month', -4, start_date) AS "-4 months",
DATE_ADD('day', -5, start_date) AS "-5 days",
DATE_ADD('hour', -6, start_date) AS "-6 hours"
FROM THIS_PROCESS
-- Filter out null values (demo'ed in Example 1)
WHERE start_date IS NOT NULL

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 125
Output:

Example 3

Because DATE_ADD both accepts and returns a timestamp, it's possible to chain together calls to this function.
For example, the following expression is valid:

DATE_ADD('week', 1, DATE_ADD('hour', 1, start_date))

However, the special handling of months means DATE_ADD isn't associative, so chaining calls to this function
can yield different results depending on the ordering of calls. Sticking with the previous input data, running the
query

SELECT start_date,
-- Column 2: Subtract a month, then add a month
DATE_ADD('month', 1, DATE_ADD('month', -1, start_date)) as "-1 then +1
month",
-- Column 3: Add a month, then subtract a month
DATE_ADD('month', -1, DATE_ADD('month', 1, start_date)) as "+1 then -1 month"
FROM THIS_PROCESS
WHERE start_date IS NOT NULL

produces the following output:

In column 2, the inner call to DATE_ADD is executed first and subtracts a month from start_date:

• Subtracting a month from '2023-01-01' yields '2022-12-01'


• Subtracting a month from '2023-01-31' yields '2022-12-31'

The outer call is then executed and adds a month to the result:

• Adding a month to '2022-12-01' yields '2023-01-01'


• Adding a month to '2022-12-31' yields '2023-01-31'

In column 3, the inner call to DATE_ADD adds a month to start_date:

• Adding a month to '2023-01-01' yields '2023-02-01'


• Adding a month to '2023-01-31' yields '2023-02-28'. Note that simply increasing the month value would
yield '2023-02-31', an invalid date, so DATE_ADD adjusts the day value to the last day in February 2023.

SAP Signavio Analytics Language Guide


126 PUBLIC SAP Signavio Analytics Language
The second call then subtracts a month from the result:

• Subtracting a month from '2023-02-01' yields '2023-01-01'


• Subtracting a month from '2023-02-28' yields '2023-01-28'

Related Information

DATE_DIFF [page 127]


DATE_TRUNC [page 132]

1.6.5.2 DATE_DIFF

Returns the period between two timestamps as a number of date or time units.

 Tip

It's also possible to calculate the period between two timestamps as a duration value using one of the
following methods:

• Subtract one timestamp from the other.


• Use the DURATION_BETWEEN function, which calculates the duration according to a given worktime
calendar.

Syntax

DATE_DIFF( <unit>, <startTimestamp>, <endTimestamp> )

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 127
Parameter Description Valid Types

unit The unit of measurement of the re- String literal

turned value.

The following units are supported:

• 'year'
• 'quarter'
• 'month'
• 'week'
• 'day'
• 'hour'
• 'minute'
• 'second'
• 'millisecond'

startTimestamp A timestamp expression. Timestamp

endTimestamp A timestamp expression. Timestamp

Returns: A number representing the period between the two timestamps. Note that:

• The number is always an integer. Fractional units aren't included.


• If a timestamp is NULL, this function returns NULL.

Handling Calendar Time

The function doesn't take calendar years, quarters, or weeks into account:

• A year is equivalent to 12 months.


• A quarter is equivalent to 3 months.
• A week is equivalent to 7 days.

The counting of months is handled specially. One month is considered elapsed each time the calendar month
can be increased without reaching the month of endTimestamp. When the month prior to endTimestamp is
reached, a further month is considered elapsed only if the day and time parts of endTimestamp are greater
than or equal to those of startTimestamp.

For example, consider the dates '2024-01-15' and '2024-04-14' as startTimestamp and endTimestamp
respectively. Beginning with January 2024, we count two increases in the calendar month until reaching March
2024, which is the month prior to April 2024. In this case, the day part of endTimestamp is less than that of
startTimestamp, so a further month isn't considered elapsed. There's therefore a two-month period between
'2024-01-15' and '2024-04-14'.

The special handling of months means that the behavior of DATE_DIFF isn't always consistent with the
behavior of the DATE_ADD function. Using DATE_ADD to add N months to date D doesn't necessarily mean that
DATE_DIFF returns N when comparing the result with D. Refer to Example 2 for a demonstration.

SAP Signavio Analytics Language Guide


128 PUBLIC SAP Signavio Analytics Language
Example 1

Let's assume we have the following data set (THIS_PROCESS):

Running the query

SELECT start_date,
end_date,
DATE_DIFF('year', start_date, end_date) AS diff_year,
DATE_DIFF('quarter', start_date, end_date) AS diff_quarter,
DATE_DIFF('month', start_date, end_date) AS diff_month,
DATE_DIFF('day', start_date, end_date) AS diff_day
FROM THIS_PROCESS

produces the following output:

Example 2

The special handling of months means that the behavior of the DATE_DIFF function isn’t always consistent
with that of the DATE_ADD function. Sticking with the previous input data, the following query shows three
values in each case: start_date, start_date with one month added to it, and the difference between the
two according to DATE_DIFF:

SELECT start_date,
DATE_ADD('month', 1, start_date) AS start_plus_1_month,
DATE_DIFF('month', start_date, (DATE_ADD('month', 1, start_date))) AS
diff_month
FROM THIS_PROCESS

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 129
Output:

In the second and third cases, the day part of start_plus_1_month is less than that of start_date, and so
this difference isn't considered a month.

To avoid this behavior, you can use the DATE_TRUNC function to restrict the precision of your timestamps to the
month level, as the following query does:

SELECT start_date,
DATE_TRUNC('month', start_date) AS start_truncated,
DATE_ADD('month', 1, DATE_TRUNC('month', start_date)) AS start_plus_1_month,
DATE_DIFF('month',
DATE_TRUNC('month', start_date),
DATE_ADD('month', 1, DATE_TRUNC('month', start_date))
) AS diff_month
FROM THIS_PROCESS

Output:

Related Information

DATE_ADD [page 123]


DATE_TRUNC [page 132]
DURATION_BETWEEN [page 134]

SAP Signavio Analytics Language Guide


130 PUBLIC SAP Signavio Analytics Language
1.6.5.3 DATE_PART

Extracts part of a date from a given timestamp.

For example, you can display the month and week of a timestamp in separate columns or you can display date
information that is not displayed by default, for example the hour.

Syntax

DATE_PART(<precision>, <expression>)

Parameter Description Valid Types

precision The precision level in single quotes for String literal

the timestamp that is returned.

Available values:

• 'year'
• 'quarter'
• 'month'
• 'week' (ISO 8601-week numbering
is applied)
• 'day'
• 'day_of_week' (returns 0 – 6, be-
ginning with Sunday = 0)
• 'hour'
• 'minute'
• 'second'
• millisecond

expression The timestamp from which you want to Timestamp


extract a part.

Returns: A Number corresponding to the value of the extracted part of the date.

Example

SELECT
"case_id",
(SELECT FIRST("end_time")) AS "Timestamp",
DATE_PART('day', (SELECT FIRST("end_time"))) AS "Day",
DATE_PART('day_of_week', (SELECT FIRST("end_time"))) AS "Day of week",
DATE_PART('week', (SELECT FIRST("end_time"))) AS "Week",
DATE_PART('month', (SELECT FIRST("end_time"))) AS "Month",
DATE_PART('year', (SELECT FIRST("end_time"))) AS "Year",
DATE_PART('hour', (SELECT FIRST("end_time"))) AS "Hour",

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 131
DATE_PART('minute', (SELECT FIRST("end_time"))) AS "Minute",
DATE_PART('second', (SELECT FIRST("end_time"))) AS "Second",
DATE_PART('millisecond', (SELECT FIRST("end_time"))) AS "Millisecond"
FROM THIS_PROCESS

This query extracts date parts from the timestamp of the cases and displays them in separate columns. If
the underlying data doesn't provide the queried precision, the value is displayed as "0", as in this example for
milliseconds.

 Example

Example output:

1.6.5.4 DATE_TRUNC

Truncates the displayed precision level of timestamps.

Truncation in this context means that all precision levels below the truncated date part of the timestamp are
displayed as "01". For example, if you truncate the timestamp with precision level "year", all months and days
are set to "01".

Syntax

DATE_TRUNC(<precision>, <expression>)

SAP Signavio Analytics Language Guide


132 PUBLIC SAP Signavio Analytics Language
Parameter Description Valid Types

precision The precision level in single quotes for String literal

the timestamp that is returned.

Available values:

• 'year'
• 'quarter'
• 'month'
• 'week' (ISO 8601-week numbering
is applied)
• 'day'
• 'hour'
• 'minute'
• 'second'
• 'millisecond'

expression The timestamp you want to truncate. Timestamp

Returns: A Timestamp with the specified truncated level of precision.

Example

SELECT
DATE_TRUNC('day', (SELECT FIRST(END_TIME))) AS "Truncated (day)",
DATE_TRUNC('month', (SELECT FIRST(END_TIME))) AS "Truncated (month)",
DATE_TRUNC('year', (SELECT FIRST(END_TIME))) AS "Truncated (year)"
FROM THIS_PROCESS

This query returns the given timestamps with truncated date parts:

• DATE_TRUNC('day') returns the timestamps unmodified because precision levels below "day" are not
displayed.
• DATE_TRUNC('month') returns the timestamps with all precision levels below month are set to "01", that is
01/mm/yyyy.
• DATE_TRUNC('year') returns the timestamps with all precision levels below year are set to "01", that is
01/01/yyyy.

 Example

Example output:

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 133
1.6.5.5 DURATION_BETWEEN

Calculates the working time between two timestamps.

The calculation is done according to a specific weekday calendar of relevant 'working' and 'non-working' time.
The built-in weekday calendars support a possible level of precision down to the millisecond.

 Note

The built-in calendars are defined at the day level. Working time for work days is considered as a full 24
hours.

Syntax

DURATION_BETWEEN(<timestampStart>, <timestampEnd>, <calendarID>)

Parameter Description Valid Types

timestampStart The start of the duration. Timestamp

timestampEnd The end of the duration. Timestamp

SAP Signavio Analytics Language Guide


134 PUBLIC SAP Signavio Analytics Language
Parameter Description Valid Types

calendarID Label referring to a weekday calendar. String (literal)

The following calendars are available:

• Monday–Friday (use label 'WEEKDAY_MTWTF')


• Monday–Saturday ('WEEKDAY_MTWTFS')
• Sunday–Thursday ('WEEKDAY_SMTWT')
• Saturday–Thursday ('WEEKDAY_SSMTWT')
• Sunday–Friday ('WEEKDAY_SMTWTF')
• Monday–Thursday and Saturday ('WEEK-
DAY_MTWT_S')

Returns: The difference between timestampStart and timestampEnd as a Duration.

Example

The query below demonstrates how the choice of weekday calendar affects calculated durations.

Three pairs of timestamps are selected. For each pair, the duration field, calculated without reference to
working time, displays the simple time difference. Each subsequent column shows how the original time
difference changes when taking into account a different weekday calendar.

 Example

SELECT case_id,
(SELECT FIRST(end_time)) AS "start",
(SELECT LAST(end_time)) AS "end",
(SELECT LAST(end_time)) - (SELECT FIRST(end_time)) AS "duration",
DURATION_BETWEEN(
(SELECT FIRST(end_time)),
(SELECT LAST(end_time)),
'WEEKDAY_MTWTF'
) AS "MTWTF",
DURATION_BETWEEN(
(SELECT FIRST(end_time)),
(SELECT LAST(end_time)),
'WEEKDAY_MTWTFS'
) AS "MTWTFS",
DURATION_BETWEEN(
(SELECT FIRST(end_time)),
(SELECT LAST(end_time)),
'WEEKDAY_SMTWT'
) AS "SMTWT",
DURATION_BETWEEN(
(SELECT FIRST(end_time)),
(SELECT LAST(end_time)),
'WEEKDAY_SSMTWT')
AS "SSMTWT",
DURATION_BETWEEN(
(SELECT FIRST(end_time)),
(SELECT LAST(end_time)),
'WEEKDAY_SMTWTF'
) AS "SMTWTF",
DURATION_BETWEEN(
(SELECT FIRST(end_time)),

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 135
(SELECT LAST(end_time)),
'WEEKDAY_MTWT_S'
) AS "MTWT_S"
FROM THIS_PROCESS
LIMIT 3

The weekdays in each case are:

• Case 00001: Saturday (01/08/2020) and Sunday (09/08/2020)


• Case 00002: Monday (06/04/2020) and Thursday (09/04/2020)
• Case 00003: Friday (21/02/2020) and Monday (02/03/2020)

Example output:

1.6.5.6 DURATION_FROM_DAYS
Converts a number of days into a Duration.

Syntax

DURATION_FROM_DAYS(<expression>)

Parameter Description Valid Types

expression Number of days. Number

Returns: A Duration, the length of time represented by the original number of days.

Example

This query demonstrates converting a number of days to a Duration.

SELECT DURATION_FROM_DAYS(3.5) AS "3 and a half days"


FROM THIS_PROCESS

Output:

SAP Signavio Analytics Language Guide


136 PUBLIC SAP Signavio Analytics Language
1.6.5.7 DURATION_FROM_MILLISECONDS

Converts a number of milliseconds into a Duration.

Syntax

DURATION_FROM_MILLISECONDS(<expression>)

Parameter Description Valid Types

expression Number of milliseconds. Number

Returns: A Duration, the length of time represented by the original number of milliseconds.

Example

This query demonstrates two instances of converting a number of milliseconds to a Duration. In both cases, the
argument has a value of 720,000 and therefore returns a duration of 12 minutes.

SELECT
DURATION_FROM_MILLISECONDS(720000) AS "Duration 1",
DURATION_FROM_MILLISECONDS(12*60*1000) AS "Duration 2"
FROM THIS_PROCESS

Output:

1.6.5.8 DURATION_TO_DAYS

Converts a Duration value into the equivalent number of days.

Syntax

DURATION_TO_DAYS(<expression>)

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 137
Parameter Description Valid Types

expression The duration to be converted. Duration

Returns: A Number, the days in the original duration. The value is a decimal and so may include fractions of a
day.

Example

This query calculates a case's duration by subtracting the last event's timestamp from the first event's
timestamp, which yields a duration. This duration becomes an argument in a call to DURATION_TO_DAYS.

SELECT case_id,
(SELECT FIRST(end_time)) AS "Start",
(SELECT LAST(end_time)) AS "End",
(SELECT LAST(end_time)) - (SELECT FIRST(end_time)) AS "Duration",
DURATION_TO_DAYS( (SELECT LAST(end_time)) - (SELECT FIRST(end_time)) ) AS
"Duration in days"
FROM THIS_PROCESS

Output:

Related Information

DURATION Literal [page 82]

SAP Signavio Analytics Language Guide


138 PUBLIC SAP Signavio Analytics Language
1.6.5.9 DURATION_TO_MILLISECONDS

Converts a Duration value into the equivalent number of milliseconds.

Syntax

DURATION_TO_MILLISECONDS(<expression>)

Parameter Description Valid Types

expression The duration to be converted. Duration

Returns: A Number, the milliseconds in the original duration.

Example

This query calculates a case's duration by subtracting the last event's timestamp from the first
event's timestamps, which yields a duration. This duration becomes an argument in two calls to
DURATION_TO_MILLISECONDS. The first call returns the number of milliseconds. The second call does the
same but is followed by a conversion of the millisecond value into minutes.

SELECT case_id,
(SELECT FIRST(end_time)) AS "Start",
(SELECT LAST(end_time)) AS "End",
(SELECT LAST(end_time)) - (SELECT FIRST(end_time)) AS "Duration",
DURATION_TO_MILLISECONDS( (SELECT LAST(end_time)) - (SELECT
FIRST(end_time)) ) AS "In ms",
DURATION_TO_MILLISECONDS( (SELECT LAST(end_time)) - (SELECT
FIRST(end_time)) ) / (1000*60) AS "In min"
FROM THIS_PROCESS

Output:

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 139
1.6.5.10 NOW

Returns the current UTC timestamp.

What is UTC?
UTC is Coordinated Universal Time, the main standard by which clocks are globally synchronized.
A UTC timestamp represents time measured at 0° longitude. All time zones are offset from UTC to calculate
local time. For example, Central European Time (CET) is UTC+1. A local time of 09:00 CET would be 08:00
UTC.

UTC doesn't change with seasons and isn't affected by daylight saving. Therefore, Central European Summer
Time (CEST) is UTC+2. A local time of 10:00 CEST would be 08:00 UTC.

Syntax

NOW()

Returns: A Timestamp corresponding to the date and time at which the query is executed.

Example

In the following example, the output of the call to NOW becomes the expression parameter value for
DATE_PART. The result displays the current quarter at the time the query is executed.

SELECT
NOW(),
DATE_PART('quarter', NOW()) as "current_quarter"
FROM THIS_PROCESS

1.6.6 String Functions

Use string functions to manipulate strings in queries.

CHAR_INDEX [page 141]


Returns the starting position of the first occurrence of a string within a second string.

CHAR_LENGTH [page 144]


Returns the number of Unicode characters contained in an input string.

CONCAT [page 145]

SAP Signavio Analytics Language Guide


140 PUBLIC SAP Signavio Analytics Language
Combines two strings into a single string value by concatenating them.

LEFT [page 147]


Returns a specified number of the leftmost Unicode characters in a string.

LOWER [page 148]


Converts all upper case characters in an input string to lower case characters.

LTRIM [page 150]


Removes all leading whitespaces from the input string.

REPLACE [page 151]


Searches a string, replacing all occurrences of a specified substring with an alternative string

REVERSE [page 153]


Returns a new string with the order of all characters from the input string reversed.

RIGHT [page 155]


Returns a specified number of the rightmost Unicode characters in a string.

RTRIM [page 156]


Removes all trailing whitespaces from the input string.

SUBSTRING [page 158]


Extracts from a string a specified number of Unicode characters beginning from a given start position.

SUBSTRING_AFTER [page 160]


Extracts from a string all Unicode characters occurring after a delimiter string.

SUBSTRING_BEFORE [page 161]


Extracts from a string all Unicode characters occurring before a delimiter string.

TRIM [page 163]


Removes all leading and trailing whitespaces from the input string.

UPPER [page 165]


Converts all lower case characters in an input string to upper case characters.

1.6.6.1 CHAR_INDEX

Returns the starting position of the first occurrence of a string within a second string.

Syntax

CHAR_INDEX(<string>, <searchString>)

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 141
Parameter Description Valid Types

string A string expression. The string to be String

searched.

If this expression is NULL, the function


returns NULL.

searchString String
The string to be located in string.

If this expression is NULL, the function


returns NULL.

Returns: A number, specifically:

• if searchString appears in string, then this function returns the starting index of the first occurrence.
• if searchString doesn't appear in string, then this function returns 0.

 Note

• The indexing is 1-based, meaning the first character in stringExpression occupies character index
1.
• The indexing counts Unicode characters.
• The function is case-sensitive. For example, the string 'case' wouldn't be found in the string
'UPPERCASE'.

Example 1

This example shows several invocations of the CHAR_INDEX function, demonstrating:

• Finding the only occurrence of a string: In this case, 'York' is searched for within 'New York'. Since the 'Y' in
'York' occupies the fifth position in the string, the function returns 5.
• Finding the first of many occurrences of a string: In this case, 'iss' is searched for within 'Mississippi'. Even
though 'iss' occurs twice, it first appears at index 2, and so the function returns 2.
• Returning 0 when failing to find a string: In this case, the function fails to find 'San' inside 'Los Angeles' and
so returns 0.
• Returning NULL when a parameter is NULL: In this case, 'Anywhere' is searched for within NULL, which can't
be searched, so the function returns NULL.

SELECT
CHAR_INDEX('New York', 'York') AS "New YORK",
CHAR_INDEX('Mississippi', 'iss') AS "MISSissippi",
CHAR_INDEX('Los Angeles', 'San') AS "Los Angeles",
CHAR_INDEX(NULL, 'Anywhere') AS "Nowhere"
FROM THIS_PROCESS

SAP Signavio Analytics Language Guide


142 PUBLIC SAP Signavio Analytics Language
Output:

Example 2

In this example, there are six types of goods for sale. We can think of these six types as being three garment
types – cappy, hoody and t-shirt – each available in two varieties: with and without a print. This query outputs
the types and the number sold.

SELECT
"Type of Goods",
COUNT("Type of Goods") AS "Number Sold"
FROM THIS_PROCESS

Output:

Let's say we want to ignore the distinction between varieties and instead count the number sold per garment
type.

The following query removes the first occurrence of a space character along with all text that follows, leaving
only the first word. The condition in the first IF function uses CHAR_INDEX to determine whether the field
includes a space character. If it doesn't, then the "Type of Goods" field is returned as is. Otherwise, a substring
of that field is extracted, specifically between the first character and the index of the first occurring space. The
index is decremented by 1 so that the space character isn't included in the substring.

SELECT
IF(
-- Checks whether a whitespace is present inside the "Type of Goods"
field.

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 143
CHAR_INDEX("Type of Goods", ' ') = 0,
-- If not, CHAR_INDEX returns 0, meaning "Type of Goods" is selected
unaltered.
"Type of Goods",
-- Otherwise, a substring of the "Type of Goods" field is returned.
SUBSTRING(
-- The substring begins at the first letter.
"Type of Goods", 1,
-- The substring ends one character before the first whitespace.
IF(
CHAR_INDEX("Type of Goods", ' ') > 0,
CHAR_INDEX("Type of Goods", ' ') - 1,
-- If neither whitespace (first IF statement) nor strings in
general
-- are found, then return NULL.
NULL
)
)
) AS "Type of Garment",
COUNT("Type of Goods") AS "Number Sold"
FROM THIS_PROCESS

Output:

Related Information

SUBSTRING [page 158]


SUBSTRING_AFTER [page 160]
SUBSTRING_BEFORE [page 161]

1.6.6.2 CHAR_LENGTH

Returns the number of Unicode characters contained in an input string.

Syntax

CHAR_LENGTH(<string>)

SAP Signavio Analytics Language Guide


144 PUBLIC SAP Signavio Analytics Language
Parameter Description Valid Types

string A string expression. String

Returns: The number of Unicode characters in the string. If the string is NULL, the function returns a NULL
value.

Example

This query displays the names of all cities in the data (THIS_PROCESS) along with the number of Unicode
characters in those names, including spaces.

SELECT
"City",
CHAR_LENGTH("City") AS "Length"
FROM THIS_PROCESS
GROUP BY 1

Output:

1.6.6.3 CONCAT

Combines two strings into a single string value by concatenating them.

CONCAT can only be applied to non-nested attributes. To use CONCAT on nested attributes, use the FLATTEN
operator. Alternatively, use a nested query that returns a single string attribute as a result.

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 145
Syntax

CONCAT(<expression1>, <expression2>)

Parameter Description Valid Types

expression1 An expression, literal or non-nested at- String


tribute.

expression2 An expression, literal or non-nested at- String


tribute.

Returns: A String, the result of appending expression2 to expression1.

Alternative syntax, which allows concatenation of an arbitrary number of strings:

<expression1> || <expression2> [ || <expressionN> ... ]

Example (Non-nested Attributes)

This query concatenates a dash to the name of every event which features the string 'ship'. It then uses the
output of that call as a parameter to a second call to CONCAT, appending the carrier name.

SELECT
COUNT(DISTINCT case_id) AS "Case Count", event_name,
"Shipment Carrier",
CONCAT(CONCAT(event_name, ' - '), "Shipment Carrier") AS "Shipment Type and
Provider"
FROM FLATTEN(THIS_PROCESS)
WHERE event_name ILIKE '%ship%'

Output:

Example (Nested Attributes)

This query selects a field from a nested attribute, using a subquery to select the first event name. Using the
alternate syntax for concatenation, it appends to this event name the case ID.

SELECT

SAP Signavio Analytics Language Guide


146 PUBLIC SAP Signavio Analytics Language
case_id,
(SELECT FIRST(event_name)) AS "Nested Attribute: Event_Name",
(SELECT FIRST(event_name)) || ' ' || case_id AS "Nested Attribute
Adjustment: Event_Name + Case_Id"
FROM THIS_PROCESS

Output:

1.6.6.4 LEFT

Returns a specified number of the leftmost Unicode characters in a string.

Syntax

LEFT(<string>, <numberOfCharacters>)

Parameter Description Valid Types

string A string expression. String

If the value is NULL, the function re-


turns NULL.

numberOfCharacters The number of leftmost characters to Number

return.

The value must be a positive integer.


Negative or fractional values result in an
error.

Returns: The specified number of leftmost characters from the string argument. If the value exceeds the
length of string, then this function returns the complete string.

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 147
Example

This query displays the names of all cities in the data (THIS_PROCESS) as well as the six leftmost characters of
each name. Names of length less than six are displayed in their entirety.

SELECT
"City",
LEFT("City", 6) AS "Leftmost6"
FROM THIS_PROCESS
GROUP BY 1

Output:

Related Information

RIGHT [page 155]


SUBSTRING [page 158]

1.6.6.5 LOWER

Converts all upper case characters in an input string to lower case characters.

Syntax

LOWER(<string>)

SAP Signavio Analytics Language Guide


148 PUBLIC SAP Signavio Analytics Language
Parameter Description Valid Types

string The string whose upper case charac- String

ters should be converted to lower case.

If the value is NULL, this function re-


turns NULL.

Returns: A new string with the same value as the string parameter but with all upper case characters
converted to lower case.

Example

Assuming the following process data (THIS_PROCESS):

This query demonstrates converting all upper case characters in the "Type of Goods" attribute to lower case:

SELECT "Type of Goods",


LOWER("Type of Goods") AS "Lower Case"
FROM THIS_PROCESS

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 149
Related Information

UPPER [page 165]

1.6.6.6 LTRIM

Removes all leading whitespaces from the input string.

The definition of a whitespace character follows the Unicode Character Database definition and includes
characters such as:

• " " (space)


• "\t" (tab)
• "\n" (newline)
• "\r" (carriage return)
• "\x0b" (line tabulation)
• "\x0c (form feed)
• "\xa0" (non-breaking space)

Syntax

LTRIM(<string>)

Parameter Description Valid Types

string The string to be trimmed. String

If the value is NULL, then this function


returns NULL.

Returns: A new string with the same value as the string parameter but with all leading whitespace characters
removed.

Related Functions

The following functions provide additional means for trimming strings:

• RTRIM: Removes all trailing whitespace characters.


• TRIM: Removes all leading and trailing whitespace characters.

SAP Signavio Analytics Language Guide


150 PUBLIC SAP Signavio Analytics Language
Example

 Note

The data in this example has been rendered so as to make all whitespace characters explicit.

Assuming the following process data (THIS_PROCESS):


| Type of Goods |
|----------------------|
| "Cappy" |
| " T-shirt\t" |
| "Cappy with Print" |
| "Hoody \r\n" |

The following query demonstrates the functions available for trimming:

SELECT "Type of Goods",


TRIM("Type of Goods") AS "TRIM",
LTRIM("Type of Goods") AS "LTRIM",
RTRIM("Type of Goods") AS "RTRIM"
FROM THIS_PROCESS

Output:
| Type of Goods | LTRIM | RTRIM |
TRIM |
|----------------------|----------------------|----------------------|-------------
---------|
| "Cappy" | "Cappy" | "Cappy" |
"Cappy" |
| " T-shirt\t" | "T-shirt\t" | " T-shirt" | "T-
shirt" |
| "Cappy with Print" | "Cappy with Print" | "Cappy with Print" | "Cappy
with Print" |
| "Hoody \r\n" | "Hoody \r\n" | "Hoody" |
"Hoody" |

Related Information

RTRIM [page 156]


TRIM [page 163]

1.6.6.7 REPLACE

Searches a string, replacing all occurrences of a specified substring with an alternative string

REPLACE can only be applied to non-nested attributes. To use REPLACE on nested attributes, use the
FLATTEN operator. Alternatively, use a nested query that returns a single string attribute as a result.

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 151
Syntax

REPLACE(<sourceExpression>, <searchExpression>, <replacementExpression>)

Parameter Description Valid Types

sourceExpression The string to be searched. An expres- String


sion or non-nested attribute.

searchExpression The substring to be replaced. An ex- String


pression or literal value.

replacementExpression The string which replaces the substring. String


An expression or literal value.

Returns: A String, the result of replacing in sourceExpression all incidences of searchExpression with
replacementExpression.

Example (Non-nested Attributes)

SELECT
DISTINCT "Type of Goods",
REPLACE("Type of Goods", 'Cappy', 'Cap') AS "Single Text Adjustment
(Literal): Cappy->Cap",
REPLACE("Type of Goods", 'w', 'W') AS "Multiple Text Adjustment (Literal):
w->W"
FROM FLATTEN(THIS_PROCESS)

Output:

Example (Nested Attributes)

SELECT
case_id,
(SELECT FIRST(event_name)) AS "Nested Attribute: Event_Name",

SAP Signavio Analytics Language Guide


152 PUBLIC SAP Signavio Analytics Language
REPLACE((SELECT FIRST(event_name)), 'Customer','Cust') AS "Nested Attribute
Adjustment: Customer->Cust"
FROM THIS_PROCESS

Output:

1.6.6.8 REVERSE

Returns a new string with the order of all characters from the input string reversed.

Syntax

REVERSE(<string>)

Parameter Description Valid Types

string A string expression to be reversed. String

If the value is NULL, this function re-


turns NULL.

Returns: A string containing all characters from the string parameter in reverse order.

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 153
Example

Assuming the following process data (THIS_PROCESS):

This query demonstrates reversing the "Type of Goods" attribute in every row:

SELECT "Type of Goods",


REVERSE("Type of Goods") AS "Reversed"
FROM THIS_PROCESS

Output:

SAP Signavio Analytics Language Guide


154 PUBLIC SAP Signavio Analytics Language
1.6.6.9 RIGHT

Returns a specified number of the rightmost Unicode characters in a string.

Syntax

RIGHT(<string>, <numberOfCharacters>)

Parameter Description Valid Types

string A string expression. String

If the value is NULL, the function re-


turns NULL.

numberOfCharacters The number of rightmost characters to Number

return.

The value must be a positive integer.


Negative or fractional values result in an
error.

Returns: The specified number of rightmost characters from the string argument. If the value exceeds the
length of string, then this function returns the complete string.

Example

This query displays the names of all cities in the data (THIS_PROCESS) as well as the six rightmost characters
of each name. Names of length less than six are displayed in their entirety.

SELECT
"City",
RIGHT("City", 6) AS "Rightmost6"
FROM THIS_PROCESS
GROUP BY 1

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 155
Output:

Related Information

LEFT [page 147]


SUBSTRING [page 158]

1.6.6.10 RTRIM

Removes all trailing whitespaces from the input string.

The definition of a whitespace character follows the Unicode Character Database definition and includes
characters such as:

• " " (space)


• "\t" (tab)
• "\n" (newline)
• "\r" (carriage return)
• "\x0b" (line tabulation)
• "\x0c (form feed)
• "\xa0" (non-breaking space)

Syntax

RTRIM(<string>)

SAP Signavio Analytics Language Guide


156 PUBLIC SAP Signavio Analytics Language
Parameter Description Valid Types

string The string to be trimmed. String

If the value is NULL, then this function


returns NULL.

Returns: A new string with the same value as the string parameter but with all trailing whitespace characters
removed.

Related Functions

The following functions provide additional means for trimming strings:

• LTRIM: Removes all leading whitespace characters.


• TRIM: Removes all leading and trailing whitespace characters.

Example

 Note

The data in this example has been rendered so as to make all whitespace characters explicit.

Assuming the following process data (THIS_PROCESS):


| Type of Goods |
|----------------------|
| "Cappy" |
| " T-shirt\t" |
| "Cappy with Print" |
| "Hoody \r\n" |

The following query demonstrates the functions available for trimming:

SELECT "Type of Goods",


TRIM("Type of Goods") AS "TRIM",
LTRIM("Type of Goods") AS "LTRIM",
RTRIM("Type of Goods") AS "RTRIM"
FROM THIS_PROCESS

Output:
| Type of Goods | LTRIM | RTRIM |
TRIM |
|----------------------|----------------------|----------------------|-------------
---------|
| "Cappy" | "Cappy" | "Cappy" |
"Cappy" |
| " T-shirt\t" | "T-shirt\t" | " T-shirt" | "T-
shirt" |
| "Cappy with Print" | "Cappy with Print" | "Cappy with Print" | "Cappy
with Print" |
| "Hoody \r\n" | "Hoody \r\n" | "Hoody" |
"Hoody" |

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 157
Related Information

LTRIM [page 150]


TRIM [page 163]

1.6.6.11 SUBSTRING

Extracts from a string a specified number of Unicode characters beginning from a given start position.

Syntax

SUBSTRING(<string>, <startPosition>, <numberOfCharacters>)

Parameter Description Valid Types

string A string expression from which the sub- String


set of characters is extracted. The value
of the string isn't altered.

startPosition The position from which to begin the Number

extraction. The index of the first charac-


ter is 1.

numberOfCharacters The number of characters to extract. Number

Returns: A string containing a subset of characters from the string parameter beginning at index
startPosition and with a length of up to numberOfCharacters. Exceptions to this include:

• If string is NULL, this function returns NULL.


• If startPosition is greater than the length of string, this function returns an empty string.
• If numberOfCharacters exceeds the length of string, this function returns the entire substring after
startPosition.

SUBSTRING_BEFORE and SUBSTRING_AFTER

SIGNAL provides alternative means of obtaining a substring when delimiters are involved.

A common use case regarding substrings is the extraction of characters occurring before or after a delimiter
or separator string. For example, let's say your process data contains a Department column containing labels
of the form "DEPT_IT", "DEPT_HR", "DEPT_FINANCE" and so on. From these labels, you wish to extract the
characters following but not including the underscore.

SAP Signavio Analytics Language Guide


158 PUBLIC SAP Signavio Analytics Language
You could achieve this by combining SUBSTRING, CHAR_INDEX, and CHAR_LENGTH:

SUBSTRING("Department", CHAR_INDEX("Department", '_') + 1,


CHAR_LENGTH("Department"))

However, SIGNAL provides a pair of functions making queries like this more convenient to write:

SUBSTRING_BEFORE(<string>, <searchString>)
SUBSTRING_AFTER(<string>, <searchString>)

These functions work by searching for the first occurrence of searchString within string and then
returning all characters before (or after) that occurrence. The example above could instead be written like
so:

SUBSTRING_AFTER("Department", '_')

Example

In this example, customer IDs have the format 'C_nnnnn'. This query selects only the numeric part of the ID by
extracting the five characters from index position three onwards.

SELECT
"Customer ID",
SUBSTRING("Customer ID", 3, 5) AS "Number Part"
FROM THIS_PROCESS

Output:

Related Information

CHAR_INDEX [page 141]


SUBSTRING_AFTER [page 160]
SUBSTRING_BEFORE [page 161]

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 159
1.6.6.12 SUBSTRING_AFTER

Extracts from a string all Unicode characters occurring after a delimiter string.

Syntax

SUBSTRING_AFTER(<string>, <searchString>)

Parameter Description Valid Types

string A string expression from which the sub- String


set of characters is extracted. The value
of the string isn't altered.

searchString A string expression that is searched for String

in the string parameter.

 Note
If searchString occurs multi-
ple times in string, the first oc-
currence is taken.

Returns: A string containing all characters from the string parameter that occur after searchString.
Exceptions include:

• If the string parameter is NULL, the function returns NULL.


• If searchString doesn't occur, this function returns NULL.

Example 1

This example shows several invocations of SUBSTRING_AFTER, demonstrating:

• Returning a substring from a string containing one delimiter.


• Returning a substring from a string containing many delimiters.
• Returning NULL when a search string isn't found.
• Returning NULL when the input string is NULL.

SELECT
SUBSTRING_AFTER('DEPT_FINANCE', '_') AS "Finance Dept.",
SUBSTRING_AFTER('DEPT_SALES_MARKETING', '_') AS "Sales & Marketing Dept.",
SUBSTRING_AFTER('DEPT_HR', '-') AS "Search String Not Found",
SUBSTRING_AFTER(NULL, '_') AS "Input String NULL"
FROM THIS_PROCESS

SAP Signavio Analytics Language Guide


160 PUBLIC SAP Signavio Analytics Language
Output:

Related Information

SUBSTRING [page 158]

1.6.6.13 SUBSTRING_BEFORE

Extracts from a string all Unicode characters occurring before a delimiter string.

Syntax

SUBSTRING_BEFORE(<string>, <searchString>)

Parameter Description Valid Types

string A string expression from which the sub- String


set of characters is extracted. The value
of the string isn't altered.

searchString A string expression that is searched for String

in the string parameter.

 Note
If searchString occurs multi-
ple times in string, the first oc-
currence is taken.

Returns: A string containing all characters from the string parameter that occur before searchString.
Exceptions include:

• If the string parameter is NULL, the function returns NULL.


• If searchString doesn't occur, this function returns NULL.

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 161
Example 1

This example shows several invocations of SUBSTRING_BEFORE, demonstrating:

• Returning a substring from a string containing one delimiter.


• Returning a substring from a string containing many delimiters.
• Returning NULL when a search string isn't found.
• Returning NULL when the input string is NULL.

SELECT
SUBSTRING_BEFORE('FINANCE_DEPT', '_') AS "Finance Dept.",
SUBSTRING_BEFORE('SALES_MARKETING_DEPT', '_') AS "Sales & Marketing Dept.",
SUBSTRING_BEFORE('HR_DEPT', '-') AS "Search String Not Found",
SUBSTRING_BEFORE(NULL, '_') AS "Input String NULL"
FROM THIS_PROCESS

Output:

Example 2

In this example, there are six types of goods for sale. We can think of these six types as being three garment
types – cappy, hoody and t-shirt – each available in two varieties: with and without a print. This query outputs
the types and the number sold.

SELECT
"Type of Goods",
COUNT("Type of Goods") AS "Number Sold"
FROM THIS_PROCESS

Output:

SAP Signavio Analytics Language Guide


162 PUBLIC SAP Signavio Analytics Language
Let's say we want to ignore the distinction between varieties and instead count the number sold per garment
type.

The following query ignores all text following the first space, if a space exists.

SELECT
IF(
SUBSTRING_BEFORE("Type of Goods", ' ') IS NOT NULL,
SUBSTRING_BEFORE("Type of Goods", ' '),
"Type of Goods"
) AS "Garment Type",
COUNT("Type of Goods") AS "Number Sold"
FROM THIS_PROCESS

Output:

Related Information

SUBSTRING [page 158]

1.6.6.14 TRIM

Removes all leading and trailing whitespaces from the input string.

The definition of a whitespace character follows the Unicode Character Database definition and includes
characters such as:

• " " (space)


• "\t" (tab)
• "\n" (newline)
• "\r" (carriage return)
• "\x0b" (line tabulation)
• "\x0c (form feed)
• "\xa0" (non-breaking space)

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 163
Syntax

TRIM(<string>)

Parameter Description Valid Types

string The string to be trimmed. String

If the value is NULL, then this function


returns NULL.

Returns: A new string with the same value as the string parameter but with all leading and trailing
whitespace characters removed.

Related Functions

The following functions provide additional means for trimming strings:

• LTRIM: Removes all leading whitespace characters.


• RTRIM: Removes all trailing whitespace characters.

Example

 Note

The data in this example has been rendered so as to make all whitespace characters explicit.

Assuming the following process data (THIS_PROCESS):


| Type of Goods |
|----------------------|
| "Cappy" |
| " T-shirt\t" |
| "Cappy with Print" |
| "Hoody \r\n" |

The following query demonstrates the functions available for trimming:

SELECT "Type of Goods",


TRIM("Type of Goods") AS "TRIM",
LTRIM("Type of Goods") AS "LTRIM",
RTRIM("Type of Goods") AS "RTRIM"
FROM THIS_PROCESS

Output:
| Type of Goods | LTRIM | RTRIM |
TRIM |
|----------------------|----------------------|----------------------|-------------
---------|
| "Cappy" | "Cappy" | "Cappy" |

SAP Signavio Analytics Language Guide


164 PUBLIC SAP Signavio Analytics Language
"Cappy" |
| " T-shirt\t" | "T-shirt\t" | " T-shirt" | "T-
shirt" |
| "Cappy with Print" | "Cappy with Print" | "Cappy with Print" | "Cappy
with Print" |
| "Hoody \r\n" | "Hoody \r\n" | "Hoody" |
"Hoody" |

Related Information

LTRIM [page 150]


RTRIM [page 156]

1.6.6.15 UPPER

Converts all lower case characters in an input string to upper case characters.

Syntax

UPPER(<string>)

Parameter Description Valid Types

string The string whose lower case characters String


should be converted to upper case.

If the value is NULL, this function re-


turns NULL.

Returns: A new string with the same value as the string parameter but with all lower case characters
converted to upper case.

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 165
Example

Assuming the following process data (THIS_PROCESS):

This query demonstrates converting all lower case characters in the "Type of Goods" attribute to upper case:

SELECT "Type of Goods",


UPPER("Type of Goods") AS "Upper Case"
FROM THIS_PROCESS

Related Information

LOWER [page 148]

SAP Signavio Analytics Language Guide


166 PUBLIC SAP Signavio Analytics Language
1.6.7 Window Functions

Learn about window functions in SIGNAL, the process mining query language of SAP Signavio Process
Intelligence.

This section explains the window functions that you can use in your SIGNAL queries.

Window functions are aggregate-like functions that you can perform over a selection of the rows which are
selected by a query. You can use window functions to perform calculations on a set of table rows that are
related to the current row in a table. In window functions, each row remains separate to the query output.
Window functions have access to all the rows that are part of the current row's group which is determined by
the PARTITION BY list of the window function.

Below is the general form of a window function: {aggregation function} OVER ([PARTITION BY
{partition expressions}] [ORDER BY {order expressions}] [[ROWS | RANGE] BETWEEN
{window frame}])

• The {aggregation function} is the function which groups the values of multiple rows to create a single
summary value.
• The ORDER BY clause sorts the data set in the PARTITION BY clause in ascending or descending order.
• The PARTITION BY clause is a subclause of the OVER clause and groups a data set into partitions.
• ROWS|RANGE modes define the scope of the {window frame}.
• The {window frame} is the set of rows related to the current row where the window function is used to
calculate the values of the defined window. You can define the window frame by using the ROW and RANGE
modes.

Limitations

Below is a list of current limitations that apply while using window functions in SIGNAL queries:

• Window functions can only be used on flat data, not on event level or nested data.
• You can't create an empty window frame when using window functions. The following are examples of
empty window frames:
• ROWS BETWEEN 1 PRECEDING AND 2 PRECEDING
• ROWS BETWEEN 1 FOLLOWING AND 1 PRECEDING
• ROWS BETWEEN 1 FOLLOWING AND CURRENT ROW

Considerations

Below is a list of considerations when using window functions in SIGNAL queries:

• Window functions are evaluated after aggregate functions in a SELECT clause.


• Window functions can only occur in SELECT clauses and on flat data. Nested data structures aren’t
supported. If you have a nested data structure like an event log, you can use window functions on case
level. If you want to use window functions on event level you can use the FLATTEN operator to create a flat
table and then use PARTITION BY case_id.

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 167
• In ORDER BY clauses, only use expressions such as column names and not numeric values for indices.

Functions

In window functions you can use aggregate and non-aggregate functions.

Aggregate functions

You can use the following aggregate functions:

• SUM
• COUNT
• MIN
• MAX
• AVG
• FIRST
• LAST
• BOOL_OR
• BOOL_AND

For more information, see Aggregate functions [page 84].

Non-aggregate functions

You can use the following non-aggregate functions:

• LAG
• LEAD
• ROW_NUMBER

For more information, see Non-aggregate functions [page 186].

1.6.7.1 Window Sort Order

Learn about window functions in SIGNAL, the process mining query language of SAP Signavio Process
Intelligence.

The ORDER BY clause sorts the data set in the PARTITION BY clause in ascending or descending order.

SAP Signavio Analytics Language Guide


168 PUBLIC SAP Signavio Analytics Language
Syntax

SELECT <columnName>, SUM(<columnName>) OVER (ORDER BY <columnName> ASC)

Parameter Description

columnName The column name in your table you want to include in the
function.

Example

Consider the following table:

City Value

Berlin 1000

Paris 3000

London 2500

Rome 1500

SELECT city, SUM(value) OVER (ORDER BY value ASC)

This query returns the cumulative sum:

City Value

Berlin 1000

Rome 2500

London 5000

Paris 8000

1.6.7.2 Window Partition

Learn about window functions in SIGNAL, the process mining query language of SAP Signavio Process
Intelligence.

The PARTITION BY clause defines the group of rows which the window function operates with. You can add
multiple expressions after the PARTITION BY. For example:

• PARTITION BY attr, ...


• PARTITION BY attr, … ORDER BY attr, ...

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 169
Syntax

SELECT column name, SUM(column name) OVER (PARTITION BY column name)

Parameter Description

column name The column name in your table you want to include in the
function.

SELECT column name, SUM(column name) OVER (PARTITION BY column name ORDER BY
column name)

Parameter Description

column name The column name in your table you want to include in the
function.

Examples

Example 1

Consider the following table:

City Value

Berlin 1000

Berlin 1800

Paris 3000

London 2500

Paris 1500

London 1200

Berlin 1300

SELECT city, SUM(value) OVER (PARTITION BY city)

A grouped sum is returned:

City Value

Berlin 4100

Berlin 4100

Berlin 4100

Paris 4500

SAP Signavio Analytics Language Guide


170 PUBLIC SAP Signavio Analytics Language
City Value

Paris 4500

London 3700

London 3700

Example 2

Consider the following table:

City Value

Berlin 1000

Berlin 1800

Paris 3000

London 2500

Paris 1500

London 1200

Berlin 1300

Now an ORDER BY is added to the function:

SELECT city, SUM(value) OVER (PARTITION BY city ORDER BY value)

The cumulative sums per city are returned:

City Value

Berlin 1000

Berlin 2300

Berlin 4100

London 1200

London 3700

Paris 1500

Paris 4500

1.6.7.3 Window Frame


Learn about window functions in SIGNAL, the process mining query language of SAP Signavio Process
Intelligence.

The window frame is the set of rows related to the current row where the window function is used to calculate
the values of the defined window. You can define the window frame by using the ROW and RANGE modes.

The window frame contains a frame_start and a frame_end. These frames are the start and end of your
window frame.

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 171
In the frame_start you can add the following keywords:

• CURRENT ROW
• UNBOUNDED PRECEDING
• offset PRECEDING

In the frame_end you can add the following keywords:

• CURRENT ROW
• UNBOUNDED FOLLOWING
• offset FOLLOWING

The frame_start of CURRENT ROW means the frame starts with the current row's first peer row (a row that the
window's ORDER BY clause sorts as equivalent to the current row). The frame_end of CURRENT ROW means
the frame ends with the current row's last peer row.

The UNBOUNDED keyword is the first or last row of the peer group with the partition.

The offset expression's data type can vary depending on the data type of the ordering column. If you use
numeric ordering columns, the type is the same as the ordering column.

If the ordering column is of the type timestamp ('10 days'), you can have the following RANGE BETWEEN '1 day'
PRECEDING AND '10 days' FOLLOWING. The offset expression must be a non-null and non-negative value.

ROWS

With the ROWS mode, you can define the start and end of the window frame in terms of rows relevant to the
current row. You can define the window frame with the ROWS mode in following ways:

• ROWS BETWEEN 10 PRECEDING AND CURRENT ROW


• ROWS BETWEEN 10 PRECEDING AND 10 FOLLOWING
• ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING

The UNBOUNDED keyword refers to the first or last row in a column or partition.

• UNBOUNDED PRECEDING is the first row


• UNBOUNDED FOLLOWING is the last row

If there is no ORDER BY clause, the returned results are undefined and the order in which the rows are
processed isn't uniform.

An offset of 0 refers to the current row.

Syntax:

SELECT column name, SUM(column name)


OVER (ORDER BY column name ASC ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING)

Parameter Description

column name The column name in your table you want to include in the
function.

SAP Signavio Analytics Language Guide


172 PUBLIC SAP Signavio Analytics Language
Example:

Consider the following table:

City Value

Berlin 1000

Paris 3000

London 2500

Paris 1500

SELECT city, SUM(value) OVER (ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING)

The following is returned:

City Value

Berlin 4000

Paris 6500

London 7000

Paris 4000

RANGE

With the RANGE mode, you can define where the window frame starts and ends in window functions. When
using the RANGE keyword the ORDER BY clause is required and you must specify one column name by which
the window frame is ordered. Using the RANGE keyword is useful when working time series and when there are
many gaps or duplicate data in your tables.

With the RANGE keyword, you can define the window frame by the maximum difference between the value of
the column in the current row and its value in the preceding or following rows of the scope.

The RANGE mode only works with data types that are of the type interval, which are numbers and timestamps.
Choice and Boolean data types aren't supported.

You can define the window frame with the RANGE mode in the following ways:

• ORDER BY attr RANGE BETWEEN 10 PRECEDING AND CURRENT ROW


• ORDER BY attr RANGE BETWEEN 1.0 PRECEDING AND 1.0 FOLLOWING
• ORDER BY attr RANGE BETWEEN DURATION "1day" PRECEDING AND DURATION "1hour" FOLLOWING
• ORDER BY attr RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING

Syntax:

SELECT column name , SUM(column name)


OVER (ORDER BY column name RANGE BETWEEN interval type PRECEDING AND interval
type FOLLOWING)

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 173
Parameter Description

column name The column name in your table you want to include in the
function.

interval type Data type which are of type interval such as numbers (1.0)
and timestamps ('10days').

Example:

Consider the following table:

City Value

Berlin 1000

Paris 3000

London 3000

Paris 2000

SELECT city, SUM(value) OVER (ORDER BY value RANGE BETWEEN 1000.0 PRECEDING AND
1000.0 FOLLOWING)

The following is returned:

City Value

Berlin 3000.0

Paris 9000.0

London 8000.0

Paris 8000.0

1.6.7.4 Window-Supporting Aggregate Functions

The functions listed in this section support windows.

Some of the standard aggregate functions can be applied to windows. This allows the function to be applied to
defined groups of rows instead of the entire table.

For more general information about windows, refer to the Window Functions overview.

 Caution

For very large data sets, these functions may require excessive CPU activity, causing long query execution
times.

For more information, refer to Performance [page 209].

AVG [page 175]


Calculates the average of a collection of numeric values. NULL values are ignored

BOOL_AND [page 176]

SAP Signavio Analytics Language Guide


174 PUBLIC SAP Signavio Analytics Language
Returns true if the supplied expression evaluates to true for all input rows, otherwise it returns false.

BOOL_OR [page 177]


Returns true if the supplied expression evaluates to true for any input row, otherwise it returns false.

COUNT [page 178]


Counts the number of values in a specified column. NULL values aren't counted.

FIRST [page 179]


Returns the first element from a collection of values.

LAST [page 180]


Returns the last element from a collection of values.

MAX [page 181]


Finds the maximum value in a collection of values.

MIN [page 182]


Finds the minimum value in a collection of values.

STDDEV [page 183]


Calculates the standard deviation for a collection of values.

SUM [page 185]


Calculates the sum of all values in a collection of numeric values. NULL values are ignored.

Related Information

Aggregate Functions [page 84]


Window Functions [page 167]

1.6.7.4.1 AVG

Calculates the average of a collection of numeric values. NULL values are ignored

Syntax

AVG(<expression>)

Parameter Description Valid Types

expression The column of values to be averaged. Number, Timestamp, Duration

Returns: The average as a Number, Timestamp or Duration. The return type matches the type of the
expression parameter.

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 175
AVG can also be used as a window function:

AVG(<expression>) OVER (
[ PARTITION BY [, <partitionExpression>, ...] ]
[ ORDER BY <orderExpression> [ { ASC | DESC } ] [, <orderExpression>, ...] [
<windowFrame> ] ]
)

For more details about this syntax, refer to the Window Functions overview.

Example

This query returns the average order amount of all cases.

SELECT AVG("Order Amount")


FROM THIS_PROCESS

Related Information

Window Functions [page 167]

1.6.7.4.2 BOOL_AND

Returns true if the supplied expression evaluates to true for all input rows, otherwise it returns false.

Syntax

BOOL_AND(<expression>)

Parameter Description Valid Types

expression An expression applied to a collection of Boolean


rows.

Returns: A Boolean. Result is true if all input rows evaluate to true for the supplied expression, otherwise false.

BOOL_AND can also be used as a window function:

BOOL_AND(<expression>) OVER (
[ PARTITION BY [, <partitionExpression>, ...] ]
[ ORDER BY <orderExpression> [ { ASC | DESC } ] [, <orderExpression>, ...] [
<windowFrame> ] ]
)

SAP Signavio Analytics Language Guide


176 PUBLIC SAP Signavio Analytics Language
For more details about this syntax, refer to the Window Functions overview.

Example

This query returns true if all rows record an approval performed by a manager.

SELECT
(SELECT BOOL_AND(event_name = 'Approve' AND performer = 'Manager'))
FROM THIS_PROCESS

Related Information

Window Functions [page 167]

1.6.7.4.3 BOOL_OR

Returns true if the supplied expression evaluates to true for any input row, otherwise it returns false.

Syntax

BOOL_OR(<expression>)

Parameter Description Valid Types

expression An expression applied to a collection of Boolean


rows.

Returns: A Boolean. Result is true if any input row evaluates to true for the supplied expression, otherwise false.

BOOL_OR can also be used as a window function:

BOOL_OR(<expression>) OVER (
[ PARTITION BY [, <partitionExpression>, ...] ]
[ ORDER BY <orderExpression> [ { ASC | DESC } ] [, <orderExpression>, ...] [
<windowFrame> ] ]
)

For more details about this syntax, refer to the Window Functions overview.

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 177
Example

This query returns true if any row records an approval performed by a manager.

SELECT
(SELECT BOOL_OR(event_name = 'Approve' AND performer = 'Manager'))
FROM THIS_PROCESS

Related Information

Window Functions [page 167]

1.6.7.4.4 COUNT

Counts the number of values in a specified column. NULL values aren't counted.

Syntax

COUNT(<expression>)

Parameter Description Valid Types

expression The column whose values are to be Any


counted.

Returns: The number of values in the provided collection of values.

COUNT can also be used as a window function:

COUNT(<expression>) OVER (
[ PARTITION BY [, <partitionExpression>, ...] ]
[ ORDER BY <orderExpression> [ { ASC | DESC } ] [, <orderExpression>, ...] [
<windowFrame> ] ]
)

For more details about this syntax, refer to the Window Functions overview.

Example

This query returns the number of cases.

SELECT COUNT(case_id)

SAP Signavio Analytics Language Guide


178 PUBLIC SAP Signavio Analytics Language
FROM THIS_PROCESS

Related Information

Window Functions [page 167]

1.6.7.4.5 FIRST

Returns the first element from a collection of values.

Syntax

FIRST(<expression>)

Parameter Description Valid Types

expression The collection of values from which the Number, Timestamp, Duration, Text,
first is chosen. Boolean

Returns: The first value as a Number, Timestamp, Duration, Text or Boolean. The return type matches the type
of the expression parameter.

FIRST can also be used as a window function:

FIRST(<expression>) OVER (
[ PARTITION BY [, <partitionExpression>, ...] ]
[ ORDER BY <orderExpression> [ { ASC | DESC } ] [, <orderExpression>, ...] [
<windowFrame> ] ]
)

For more details about this syntax, refer to the Window Functions overview.

Example

This query returns the name of the first event in this process.

SELECT
(SELECT FIRST(event_name))
FROM THIS_PROCESS

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 179
Related Information

Window Functions [page 167]

1.6.7.4.6 LAST

Returns the last element from a collection of values.

Syntax

LAST(<expression>)

Parameter Description Valid Types

expression The collection of values from which the Number, Timestamp, Duration, Text,
last is chosen. Boolean

Returns: The last value as a Number, Timestamp, Duration, Text or Boolean. The return type matches the type
of the expression parameter.

LAST can also be used as a window function:

LAST(<expression>) OVER (
[ PARTITION BY [, <partitionExpression>, ...] ]
[ ORDER BY <orderExpression> [ { ASC | DESC } ] [, <orderExpression>, ...] [
<windowFrame> ] ]
)

For more details about this syntax, refer to the Window Functions overview.

Example

This query returns the name of the last event in this process.

SELECT
(SELECT LAST(event_name))
FROM THIS_PROCESS

Related Information

Window Functions [page 167]

SAP Signavio Analytics Language Guide


180 PUBLIC SAP Signavio Analytics Language
1.6.7.4.7 MAX

Finds the maximum value in a collection of values.

Syntax

MAX(<expression>)

Parameter Description Valid Types

expression The collection from which the maxi- Number, Timestamp, Duration
mum value is chosen.

Returns: The maximum value as a Number, Timestamp or Duration. The return type matches the type of the
expression parameter.

MAX can also be used as a window function:

MAX(<expression>) OVER (
[ PARTITION BY [, <partitionExpression>, ...] ]
[ ORDER BY <orderExpression> [ { ASC | DESC } ] [, <orderExpression>, ...] [
<windowFrame> ] ]
)

For more details about this syntax, refer to the Window Functions overview.

Example

This query returns the largest discount.

SELECT MAX(discount)
FROM THIS_PROCESS

Related Information

Window Functions [page 167]

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 181
1.6.7.4.8 MIN

Finds the minimum value in a collection of values.

Syntax

MIN(<expression>)

Parameter Description Valid Types

expression The collection from which the minimum Number, Timestamp, Duration
value is chosen.

Returns: The minimum value as a Number, Timestamp or Duration. The return type matches the type of the
expression parameter.

MIN can also be used as a window function:

MIN(<expression>) OVER (
[ PARTITION BY [, <partitionExpression>, ...] ]
[ ORDER BY <orderExpression> [ { ASC | DESC } ] [, <orderExpression>, ...] [
<windowFrame> ] ]
)

For more details about this syntax, refer to the Window Functions overview.

Example

This query returns the smallest discount.

SELECT MIN(discount)
FROM THIS_PROCESS

Related Information

Window Functions [page 167]

SAP Signavio Analytics Language Guide


182 PUBLIC SAP Signavio Analytics Language
1.6.7.4.9 STDDEV
Calculates the standard deviation for a collection of values.

The standard deviation describes the average deviation of all measured values from the mean value. A low
standard deviation indicates that the values tend to be close to the mean value. A high standard deviation
indicates that the values are spread out over a wide range.

Syntax

STDDEV(<expression>)

Parameter Description Valid Types

expression The collection of values for which you Number, Timestamp, Duration
want to determine the standard devia-
tion.

Returns: The standard deviation as a Number, Timestamp, or Duration. The return type matches the type of
the expression parameter.

STDDEV can also be used as a window function:

STDDEV(<expression>) OVER (
[ PARTITION BY [, <partitionExpression>, ...] ]
[ ORDER BY <orderExpression> [ { ASC | DESC } ] [, <orderExpression>, ...] [
<windowFrame> ] ]
)

For more details about this syntax, refer to the Window Functions overview.

Example 1

This query returns the standard deviation of all order amounts.

SELECT
MIN("Order Amount") AS "Min",
MAX("Order Amount") AS "Max",
AVG("Order Amount") AS "Avg",
STDDEV("Order Amount") AS "StdDev"
FROM THIS_PROCESS

Output:

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 183
Example 2

This query shows how the cycle time of a process changes week-to-week. Specifically, it calculates both the
average and the standard deviation of the cycle time on a weekly basis.

To smooth out short-term fluctuations in the data, it uses windowed versions of the average (AVG) and
standard deviation (STDDEV) functions. These versions calculate a moving average and moving standard
deviation for the weekly mean cycle time respectively.

In the nested query, sq1, all cases are clustered together by week. The mean cycle time within each cluster is
calculated.

The outer query applies the windowed AVG and STDDEV functions to the weekly mean cycle time. In both cases,
the window includes the three weeks preceding and the three weeks following the current week.

SELECT
"Week",
"Avg Cycle Time",
AVG("Avg Cycle Time") OVER (ROWS BETWEEN 3 PRECEDING AND 3 FOLLOWING) as
mean,
STDDEV("Avg Cycle Time") OVER (ROWS BETWEEN 3 PRECEDING AND 3 FOLLOWING) as
std
FROM
(
SELECT
DATE_TRUNC('WEEK', (SELECT LAST (END_TIME))) AS "Week",
AVG((SELECT LAST(end_time) - FIRST(end_time))) AS "Avg Cycle Time"
FROM THIS_PROCESS
ORDER BY 1 ASC NULLS FIRST
FILL timeseries('WEEK')
) as sq1

SAP Signavio Analytics Language Guide


184 PUBLIC SAP Signavio Analytics Language
Related Information

Window Functions [page 167]

1.6.7.4.10 SUM

Calculates the sum of all values in a collection of numeric values. NULL values are ignored.

Syntax

SUM(<expression>)

Parameter Description Valid Types

expression The collection of values to be summed. Number, Duration

Returns: The sum as a Number or Duration. The return type matches the type of the expression parameter.

SUM can also be used as a window function:

SUM(<expression>) OVER (
[ PARTITION BY [, <partitionExpression>, ...] ]
[ ORDER BY <orderExpression> [ { ASC | DESC } ] [, <orderExpression>, ...] [
<windowFrame> ] ]
)

For more details about this syntax, refer to the Window Functions overview.

Example

This query returns the total order amount in Boston.

SELECT SUM("ORDER AMOUNT")


FROM THIS_PROCESS
WHERE("City" = 'Boston')

Related Information

Window Functions [page 167]

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 185
1.6.7.5 Non-Aggregate Functions

The functions in this section do not aggregate collections of values into a single value. They are applied to
individual rows within a window.

For more general information about windows, refer to the Window Functions overview.

 Caution

For very large data sets, these functions may require excessive CPU activity, causing long query execution
times.

For more information, refer to Performance [page 209].

LAG [page 186]


Returns a single column value from the preceding row according to the window partition and sort
criteria. When no preceding row exists, a null value is returned.

LEAD [page 188]


Returns a single column value from the succeeding row according to the window partition and sort
criteria. When no succeeding row exists, a null value is returned.

OCCURRENCE [page 189]


Returns a list of numbers representing a running occurrence count of distinct items in an event list.

Related Information

Window Functions [page 167]

1.6.7.5.1 LAG

Returns a single column value from the preceding row according to the window partition and sort criteria.
When no preceding row exists, a null value is returned.

Syntax

LAG(<columnName>) OVER (
[ PARTITION BY <partitionExpression> [, <partitionExpression>, ... ] ]
ORDER BY <sortExpression>
)

SAP Signavio Analytics Language Guide


186 PUBLIC SAP Signavio Analytics Language
Parameter Description

columnName The column from the preceding row to be included in the


current row.

partitionExpression An expression determining how the rows are grouped.

sortExpression An expression determining how each partition is sorted.

Example

This query partitions data by case ID, sorting each partition chronologically. Each row includes the case ID and
event name along with two additional columns:

• The event name from the preceding row


• The difference between the timestamps of the preceding and current rows

The result shows the name of each event that occurred, the name of the preceding event and how much time
separates the two events. For events having no predecessor, a null value is displayed.

SELECT
case_id,
LAG(event_name) OVER (PARTITION BY case_id ORDER BY end_time) AS Predecessor,
event_name AS Event,
end_time - LAG(end_time) OVER (PARTITION BY case_id ORDER BY end_time) AS
cycle_time
FROM FLATTEN(THIS_PROCESS)

 Example

Example output:

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 187
1.6.7.5.2 LEAD

Returns a single column value from the succeeding row according to the window partition and sort criteria.
When no succeeding row exists, a null value is returned.

Syntax

LEAD(<columnName>) OVER (
[ PARTITION BY <partitionExpression> [, <partitionExpression>, ... ] ]
ORDER BY <sortExpression>
)

Parameter Description

columnName The column from the succeeding row to be included in the


current row.

partitionExpression An expression determining how the rows are grouped.

sortExpression An expression determining how each partition is sorted.

Example

This query partitions data by case ID, sorting each partition chronologically. Each row includes the case ID and
event name along with two additional columns:

• The event name from the next row


• The difference between the timestamps of the current and succeeding rows

The result shows the name of each event that occurred, the name of the succeeding event and how much time
separates the two events. For events having no successor, a null value is displayed.

SELECT
case_id,
event_name AS Event,
LEAD(event_name) OVER (PARTITION BY case_id ORDER BY end_time) AS Successor,
LEAD(end_time) OVER (PARTITION BY case_id ORDER BY end_time) - end_time AS
CycleTime
FROM FLATTEN(THIS_PROCESS)

 Example

Example output:

SAP Signavio Analytics Language Guide


188 PUBLIC SAP Signavio Analytics Language
1.6.7.5.3 OCCURRENCE

Returns a list of numbers representing a running occurrence count of distinct items in an event list.

The function operates at event level. When applied to an event column, it calculates a running total of
occurrences for each distinct value in the event list. At each step, it adds to a list the number of item
occurrences up to that point.

Syntax

<aggregateFunction> ( <occurrenceAlias> )
FROM ( SELECT OCCURRENCE( <expression> ) AS <occurrenceAlias> ) AS
<subqueryAlias>

Parameter Description

aggregateFunction The name of an aggregate function.

occurrenceAlias An alias for the OCCURRENCE function's output for the ag-
gregate function to use.

expression An expression that evaluates to an event-level column.

subqueryAlias An alias for the subquery.

Returns: A list of numbers containing the running totals of each distinct item in expression. Note that:

• If expression is NULL, then OCCURRENCE returns NULL.

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 189
• Any NULL values in the expression column are ignored.
• If the expression column contains only NULL values, OCCURRENCE returns NULL.

Behavior

To illustrate the function's behavior, let's imagine an event column containing six values: ["A", "B", "A",
"C", "B", "A"]. The following table shows how OCCURRENCE proceeds to calculate a return value for this
column as it encounters each value:

Return Value of
Value Number Value Remark OCCURRENCE So Far

1 "A" Encounters 1st occurrence [1]


of A

2 "B" Encounters 1st occurrence [1, 1]


of B

3 "A" Encounters 2nd occurrence [1, 1, 2]


of A

4 "C" Encounters 1st occurrence [1, 1, 2, 1]


of C

5 "B" Encounters 2nd occurrence [1, 1, 2, 1, 2]


of B

6 "A" Encounters 3rd occurrence [1, 1, 2, 1, 2, 3]


of A

The function therefore returns the list [1, 1, 2, 1, 2, 3].

Example

The OCCURRENCE function is useful for identifying cases containing rework, indicated by repeated events. The
following query selects the ID and the list of event names for each case.

SELECT case_id, "event_name"


FROM THIS_PROCESS
WHERE (
SELECT MAX(occ) FROM (
SELECT OCCURRENCE(event_name) AS occ
) AS sub
) >= 4

The result set is filtered by the subquery in the WHERE clause. The OCCURRENCE function is applied to the
event_name column, which returns a list of running occurrences of each event. The MAX function finds the
largest number in this list, indicating the number of times the most repeated event occurred per case. Only
cases containing an event that was worked more than or equal to four times are included in the result.

SAP Signavio Analytics Language Guide


190 PUBLIC SAP Signavio Analytics Language
A refinement of this example demonstrates this function's utility as a window function. Instead of the
maximum, let's select the average event occurrence and restrict the result set to the case with ID '00098',
the events from which are in the previous image.

SELECT
case_id,
(
SELECT AVG(occ) FROM (
SELECT OCCURRENCE(event_name) AS occ
) AS sub
) AS "Average"
FROM THIS_PROCESS
WHERE case_id = '00098'

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 191
Output:

The OCCURRENCE function determines for each value the number of occurrences up to the current point. The
occurrence values for case '00098' are [1, 1, 2, 3, 4, 1, 1]. Consequently, the AVG function calculates
case '00098' as 1.857, the sum of its occurrence values (13) divided by the number of elements (7).

Related Information

Aggregate Functions [page 84]


Event-Level Subqueries [page 47]
RANK [page 195]

1.6.7.6 Ranking Functions

The functions in this section are window functions that sort data partitions and assign a rank value for each row
within a result set.

Using these functions, you can filter the results and sort them for consistent stacking in visualizations such as
stacked bar charts.

 Caution

For very large data sets, these functions may require excessive CPU activity, causing long query execution
times.

For more information, refer to Performance [page 209].

DENSE_RANK [page 193]


Returns the rank of each row in a result set based on the order defined in the OVER clause for each
partition

RANK [page 195]


Returns the rank of each row in a result set based on the order defined in the OVER clause for each
partition.

ROW_NUMBER [page 197]


Returns the calculated row number based on partitioned and sorted set of values.

SAP Signavio Analytics Language Guide


192 PUBLIC SAP Signavio Analytics Language
1.6.7.6.1 DENSE_RANK

Returns the rank of each row in a result set based on the order defined in the OVER clause for each partition

The DENSE_RANK function assigns the same ranking for rows with identical values and doesn't skip the rank
positions for these identical rows. For example, rows with rank values, 1, 2, 2, 2, 3, 4. The rank value of the next
nonidentical row will have the succeeding rank.

Syntax

DENSE_RANK() OVER (
[ PARTITION BY <expression> [, <expression>, ...] ]
[ ORDER BY <expression> [ { ASC | DESC } ] [, <expression>, ...] ]
)

Parameters Description

expression The column or argument determining how the rows are


grouped and how each partition is sorted. Mandatory if PAR-
TITION BY or ORDER BY clauses are included in the query.

PARTITION BY: Splits the result set into partitions. Optional.

ORDER BY: Sorts each partition based on the defined criteria. Optional. If ORDER BY clause isn't included in
your query, each row will have the same rank value, one.

ASC | DESC: ASC sorts the result set in ascending order and DESC sorts it in descending order based on the
expressions defined in ORDER BY.

Example 1

In the following query, the cities are first partitioned by the type of good and sorted by the count of high value
orders per Type of Goods. The query then returns the cities with order amount greater than 1500 ranked in
descending order.

SELECT "Type of Goods",


"City",
count(case_id) AS "Orders > $1500",
ROW_NUMBER() OVER (PARTITION BY "Type of Goods" ORDER BY count(case_id)
DESC) AS "ROW_NUMBER",
RANK() OVER (PARTITION BY "Type of Goods" ORDER BY count(case_id) DESC)
AS "RANK",
DENSE_RANK() OVER (PARTITION BY "Type of Goods" ORDER BY count(case_id)
DESC) AS "DENSE_RANK"
FROM THIS_PROCESS
WHERE "Order Amount" > 1500
GROUP BY 1,2

 Example

Result:

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 193
Example 2

The following query partitions the result set by the type of goods and returns the list of cities with order amount
greater than 1500 within a partition. In the result set, the RANK and DENSE RANK of all the returned rows is
one as the ORDER BY clause isn't included in the query.

SELECT "Type of Goods",


"City",
count(case_id) AS "Orders > $1500",
ROW_NUMBER() OVER () AS "ROW_NUMBER",
RANK() OVER () AS "RANK",
DENSE_RANK() OVER () AS "DENSE_RANK"
FROM THIS_PROCESS
WHERE "Order Amount" > 1500

 Example

Result:

SAP Signavio Analytics Language Guide


194 PUBLIC SAP Signavio Analytics Language
1.6.7.6.2 RANK

Returns the rank of each row in a result set based on the order defined in the OVER clause for each partition.

The RANK function assigns the same ranking for rows with identical values and skips the rank positions for
these identical rows. For example, rows with rank values, 1, 2, 2, 2, 5, 6. The rank value of the next nonidentical
row depends on the number of rows with same ranking. The number of rows with the same ranking determines
the number of rank values to be skipped.

Syntax

RANK() OVER (
[ PARTITION BY <expression> [, <expression>, ...] ]
[ ORDER BY <expression> [ { ASC | DESC } ] [, <expression>, ...] ]
)

Parameters Description

expression The column or argument determining how the rows are


grouped and how each partition is sorted. Mandatory if PAR-
TITION BY or ORDER BY clauses are included in the query.

PARTITION BY: Splits the result set into partitions. Optional.

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 195
ORDER BY: Sorts each partition based on the defined criteria. Optional.

ASC | DESC: ASC sorts the result set in ascending order and DESC sorts it in descending order based on the
expressions defined in ORDER BY.

Example

In the following query, the cities are first partitioned by the type of good and sorted by the count of high value
orders per Type of Goods. The query then returns the cities with order amount greater than 1500 ranked in
descending order.

SELECT "Type of Goods",


"City",
count(case_id) AS "Orders > $1500",
ROW_NUMBER() OVER (PARTITION BY "Type of Goods" ORDER BY count(case_id)
DESC) AS "ROW_NUMBER",
RANK() OVER(PARTITION BY "Type of Goods" ORDER BY count(case_id) DESC) AS
"RANK"
FROM THIS_PROCESS
WHERE "Order Amount" > 1500
GROUP BY 1, 2

 Example

Result:

SAP Signavio Analytics Language Guide


196 PUBLIC SAP Signavio Analytics Language
1.6.7.6.3 ROW_NUMBER

Returns the calculated row number based on partitioned and sorted set of values.

The ranking happens sequentially based on the order defined in the OVER clause for each partition. The rank
value is different even if the rows contain the same values.

Syntax

ROW_NUMBER() OVER (
[ PARTITION BY <expression> [, <expression>, ...] ]
[ ORDER BY expression [ { ASC | DESC } ] [, <expression>, ...] ]
)

Parameters Description

expression The column or argument that determines how the rows are
grouped and how each partition is sorted. Mandatory if PAR-
TITION BY or ORDER BY clauses are included in the query.

PARTITION BY: Splits the result set into partitions. Optional.

ORDER BY: Sorts each partition based on the defined criteria. Optional.

ASC | DESC: ASC sorts the result set in ascending order and DESC sorts it in descending order based on the
expressions defined in ORDER BY.

Example

In the following query, the order amount is first partitioned based on the city and the type of good. The query
then returns the order amount ranked in descending order in the result set.

SELECT "Type of Goods",


"City",
"Order Amount",
ROW_NUMBER() OVER (PARTITION BY "Type of Goods", "City" ORDER BY "Order
Amount" DESC)
FROM THIS_PROCESS
WHERE "Order Amount" > 1500
ORDER BY 1, 2, 4

 Example

Result:

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 197
1.6.8 BUCKET Function

Learn about the BUCKET() function in SIGNAL, the process mining query language of SAP Signavio Process
Intelligence.

The BUCKET() function calculates the indexes of values in a range of values (as buckets) that are equal in
size. The bucket indexes can then be applied to an aggregate function, for example a COUNT() function, which
counts the values within that bucket.

The BUCKET() function uses following parameters to calculate the bucket indexes as a positive integer
number:

• The value to be bucketed (expression)


• The minimum value within the result range (min)
• The fixed width for each bucket (bucket_width)
• The total number of consecutive, non-overlapping buckets (#_inlier_buckets)

Syntax:

BUCKET(expression, min, bucket_width, #_inlier_buckets)

Parameter Description

expression Specify a column with numeric or duration values in the


expression.

SAP Signavio Analytics Language Guide


198 PUBLIC SAP Signavio Analytics Language
Parameter Description

min The starting value of the bucket. The values must be either
numeric or duration values.

bucket_width The width of the bucket. The value must be either a positive
numeric or positive duration [page 6] that is greater than
zero.

#_inlier_buckets The number of required buckets. The value must be a posi-


tive integer that is greater than or equal to one.

To understand the range of values in the bucket, you can first determine the bucket boundaries and then apply
the boundaries to the BUCKET() function. To determine the bucket boundaries and then apply the boundaries
to the BUCKET() function, use the following pattern:

SELECT
IF (b = 0, NULL, ((b - 1) * bucket_width) + min) AS bucket_start,
IF (b = #_inlier_buckets + 1, NULL, (b * bucket_width) + min) AS bucket_end,
value
FROM (
SELECT BUCKET(expression, bucket_start, bucket_width, #_inlier_buckets) AS b,
COUNT(1) AS value
FROM ...
) AS sub

The bucket boundaries pattern isn't required for the BUCKET() function to work. It provides a useful way to
understand the range of values in the bucket. The pattern defines the minimum and maximum values being
aggregated in the bucket.

Example 1:

The following example calculates the bucket boundaries (bucket_start and bucket_end). Then aggregates the
total number of cases based on 'Order Amount'. The cases are bucketed into intervals of 100€ (bucket_width).

The results are then calculated for 100 buckets (#_inlier_buckets) where the 'Order Amount' is greater than 1€
(min) and less than 10001€ (max). The maximum value is calculated with the following formula: min + bucket
width x #_inlier_buckets = 1+ 100 x 100 = 10001.

SELECT
total_cases,
bucket_id,
IF (bucket_id > 100, -1, ((bucket_id-1) * 100) + 0) AS bucket_start,
IF (bucket_id > 100, -1, (bucket_id * 100) + 0) AS bucket_end
FROM (
SELECT
BUCKET("Order Amount", 1, 100,100) as bucket_id,
COUNT(case_id) as total_cases
FROM FLATTEN(THIS_PROCESS)
WHERE "Order Amount" is not null
GROUP BY 1
ORDER BY 1
) as sub

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 199
Result:

Example 2:

The following example aggregates the total number of cases based on the 'Order Amount'. The cases are
bucketed into intervals of 100€ (bucket_width). The results are calculated for 10 buckets (#_inlier_buckets)
where the 'Order Amount' is greater than 1€ (min) and less than 1001€ (max). The maximum value is
calculated with the following formula: min + bucket width x #_inlier_buckets = 1 + 100 x 10 = 1001

The result displays in a breakdown widget. The values on the X axis represent the bucket ID. Buckets that
contain at least one case within them are displayed. The cases that have a bucket value of 10 but exceed the
maximum value are added into the outlier bucket. The outlier bucket has a bucket ID of 11.

SELECT
BUCKET("Order Amount", 1, 100,10) as order_amount,
COUNT(case_id)
FROM FLATTEN(THIS_PROCESS)
WHERE "Order Amount" is not null
GROUP BY 1
ORDER BY 1

Result:

SAP Signavio Analytics Language Guide


200 PUBLIC SAP Signavio Analytics Language
1.6.9 Numeric Rounding Functions

Learn about the numeric rounding functions in SIGNAL, the process mining query language of SAP Signavio
Process Intelligence.

The numeric rounding functions simplify calculations by converting floating-point numbers to an approximate
value that is shorter, clearer, and easier to remember.

These functions help group data, set threshold values for comparisons or histogram bucketing, and calculate
complex value expressions such as cost or duration.

Functions and Syntax

Following are the numeric rounding functions:

Function Description Syntax

CEIL The ceiling function returns the near- CEIL(numericAttribute)

est integer greater than or equal to the


provided numeric value by rounding to-
wards positive infinity.

For example,

• 10.56 is rounded to 11
• -10.56 is rounded to -10

FLOOR The floor function returns the nearest FLOOR(numericAttribute)

integer less than or equal to the pro-


vided numeric value by rounding to-
wards negative infinity.

For example,

• 10.56 is rounded to 10
• -10.56 is rounded to -11

ROUND The round function returns the nearest ROUND(numericAttribute)

integer value to the provided numeric


value.

For example,

• 10.45 is rounded to 10
• 10.56 is rounded to 11
• -10.45 is rounded to -10
• -10.5 is rounded to -11

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 201
Function Description Syntax

TRUNC The truncate function returns the inte- TRUNC(numericAttribute)

ger part of the provided numeric value


by rounding towards zero.

For example,

• 10.45 is rounded to 10
• -10.5 is rounded to -10

Parameter Description

numericAttribute A numeric column or literal value.

Examples

Example 1

The following query returns the order amount rounded up or down to the nearest integer value based on the
specified function.

SELECT "case_id",
"Order Amount",
CEIL("Order Amount") AS "Order Amount - Ceiling",
FLOOR("Order Amount") AS "Order Amount - Floor",
ROUND("Order Amount") AS "Order Amount - Round",
TRUNC("Order Amount") AS "Order Amount - Truncated",
FROM THIS_PROCESS
LIMIT 10

Result:

The query returns the following result.

SAP Signavio Analytics Language Guide


202 PUBLIC SAP Signavio Analytics Language
Example 2

The following query shows how each function rounds up the negative values.

SELECT CEIL(-1.5) AS "Literal -1.5 - Ceiling",


FLOOR(-1.5) AS "Literal -1.5 - Floor",
ROUND(-1.5) AS "Literal -1.5 - Round",
TRUNC(-1.5) AS "Literal -1.5 - Truncated"
FROM THIS_PROCESS
LIMIT 1

Result:

The query returns the following result.

1.7 Keywords

Keywords are words with special significance in SIGNAL, meaning they cannot be used as identifiers in a query.
If you wish to use a keyword as an identifier, you must enclose it in double quotation marks.

For example, the query

SELECT SUM("Order Value") AS Sum FROM THIS_PROCESS

is invalid because it tries to give the selected column an alias of 'Sum'. However, 'SUM' – being the name of
a function – is a SIGNAL keyword. (SIGNAL keywords are case-insensitive, so the difference in case is of no
consequence.) To use 'Sum' as an identifier, you would have to enclose it in double quotation marks, like so:

SELECT SUM("Order Value") AS "Sum" FROM THIS_PROCESS

The following alphabetically organized lists contain all SIGNAL keywords.

• ABS
• ALL
• ANALYZE
• AND
• ANY
• AS
• ASC

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 203
• AVG

• BARRIER
• BEHAVIOUR
• BETWEEN
• BOOL_AND
• BOOL_OR
• BUCKET
• BY

• CASE
• CASE_ID
• CATEGORY
• CEIL
• CHAR_INDEX
• CHAR_LENGTH
• COALESCE
• CONCAT
• COUNT
• CREATE
• CURRENT

• DATE_ADD
• DATE_DIFF
• DATE_PART
• DATE_TRUNC
• DEFAULT
• DENSE_RANK
• DESC
• DESCRIBE
• DISTINCT
• DROP

SAP Signavio Analytics Language Guide


204 PUBLIC SAP Signavio Analytics Language
• DURATION
• DURATION_BETWEEN
• DURATION_FROM_DAYS
• DURATION_FROM_MILLISECONDS
• DURATION_TO_DAYS
• DURATION_TO_MILLISECONDS

• ELSE
• END
• END_TIME
• EVENT_ID
• EVENT_NAME
• EVENTS
• EXACT
• EXPLAIN
• EXTERNAL

• FALSE
• FILL
• FILTER
• FIRST
• FLATTEN
• FLOOR
• FOLLOWING
• FORMAT
• FROM

• GRANT
• GROUP

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 205
H

• HAVING

• IF
• ILIKE
• IN
• INVOKER
• IS

• JOIN
• JSON

• LAG
• LAST
• LEAD
• LEFT
• LIKE
• LIMIT
• LOCATION
• LOG

• MATCHES
• MAX
• MEDIAN
• MIN

SAP Signavio Analytics Language Guide


206 PUBLIC SAP Signavio Analytics Language
N

• NOT
• NOW
• NULL
• NULLS

• OCCURRENCE
• ODATA
• OFFSET
• ON
• ONLY
• OR
• ORDER
• OUTER
• OVER

• PARQUET
• PARTITION
• PERCENT
• PERCENTILE_CONT
• PERCENTILE_DESC
• PERMISSIONS
• POW
• PRECEDING
• PRIVATE
• PUBLIC

• RANGE
• RANK
• REGR_INTERCEPT

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 207
• REGR_SLOPE
• REPEATABLE
• REPLACE
• RIGHT
• ROUND
• ROW
• ROW_NUMBER
• ROWS

• SECURITY
• SELECT
• SIGN
• SQRT
• START_TIME
• STDDEV
• SUBSTRING
• SUBSTRING_AFTER
• SUBSTRING_BEFORE
• SUM

• TABLE
• TABULAR
• TEXT
• THEN
• TIMESERIES
• TIMESTAMP
• TO
• TO_NUMBER
• TO_STRING
• TO_TIMESTAMP
• TRUE
• TRUNC

SAP Signavio Analytics Language Guide


208 PUBLIC SAP Signavio Analytics Language
U

• UNBOUNDED
• UNION
• USING

• VIEW

• WHEN
• WHERE
• WITH
• WITHIN

1.8 Performance

The SIGNAL Engine processes queries and can handle very large data sets rapidly, although some factors can
affect performance.

Event Log Size

The SIGNAL Engine performs numerous optimizations automatically to maximize query performance. In
general, the engine can comfortably handle event logs consisting of up to 1 billion entries.

For a certain subset of language features, performance can suffer when operating on a data set of very large
size. This can compromise the execution time of the containing query. A function or operator is considered
vulnerable to performance issues if its execution time tends to be greater than five seconds when running
on a data set of 1 billion events. All functions and operators prone to such performance issues are flagged
accordingly in their documentation.

SAP Signavio Analytics Language Guide


SAP Signavio Analytics Language PUBLIC 209
Timeout

In SIGNAL, the timeout length of a query is 10 minutes. Once a query has run for 10 minutes without result,
that query is terminated and an error is returned.

 Tip

If you receive a timeout error, refreshing your browser triggers a restart of the query. A result may be
returned by this subsequent attempt, however it isn't guaranteed.

SAP Signavio Analytics Language Guide


210 PUBLIC SAP Signavio Analytics Language
2 Tutorial

Learn about using SIGNAL in the following tutorial, the process mining query language of SAP Signavio Process
Intelligence.

This tutorial supports you to get started with SIGNAL.

Based on a sample process with test data, this tutorial introduces you to the main principles of SIGNAL,
starting from simple case-attribute based queries to more complex event-based queries.

The tutorial is structured as follows:

Section Examples Learning success Introduced keywords

Count cases and cities • How many cases exist • Count a case attribute COUNT
for this process? • Count the distinct re-
COUNT DISTINCT
• How many different cit- cords of a case attribute
ies are involved in this • Count two or more case AS
process? attributes ORDER BY
• How many cases exist • Rename case attribute
WHERE
for each city? names with alias names
• How many cases exist • Sort the result set IN
for New York and Miami? • Filter a result set to in-
clude only records that
fulfill a specified condi-
tion

Analyze order amounts • What is the average or- • Determine the average AVG
der amount of this proc- value of a case attribute
SUM
ess? • Determine a filtered
• What is the average or- average case attribute FILTER
der amount in Houston? • Sum up a case attribute
• What is the total order • Determine the percent-
amount in Boston? age value of a case at-
• What is the percentage tribute compared to the
order amount in Boston overall value
compared to the total • Apply filter condition(s)
order amount? within a query

Determine process cycle • How long is the average • Calculate cycle times MAX
times
cycle time of all cases? • Perform subqueries on
MIN
• How long is the average event attributes
cycle time by city? • Determine cycle time by
• What are the maxi- case attribute
mum / minimum cycle • Calculate the largest /
times by city? smallest values

SAP Signavio Analytics Language Guide


Tutorial PUBLIC 211
Section Examples Learning success Introduced keywords

Investigate events • How many cases have • Counting the total num- IF
been closed / canceled? ber of events
NOT
• What is the drop-out • Filter for not true condi-
rate? tions MATCHES

• How many cases follow • Determine the process


the standard process? conformance
• How many cases are
canceled although the T-
shirts have been sent for
printing?

2.1 Understand the sample process

Understand the sample process used in the SIGNAL tutorial.

This tutorial is using the following sample process:

 Note

For a more detailed view of the process flow, check the Process Discovery widget of the sample process.

In this tutorial, the following case and event attributes are used:

• Case attributes
• Case ID
• City
• Order Amount in EUR
• Event attributes
• EventName

SAP Signavio Analytics Language Guide


212 PUBLIC Tutorial
• Timestamp

Example (extract):

 Note

For more detailed information about the test data, check them under Process Settings > Data in the sample
process.

2.2 Count cases and cities

Read about the overview of case attributes used in the SIGNAL tutorial.

You want to get an overview about the case attributes of the process: How many cases exist for this process?
How many different cities are involved in this process? How many cases exist for each city? How many cases
exist for New York and Miami?

Example 1: How many cases exist for this process?

Learning success: Count a case attribute.

Query instruction: Count (keyword: COUNT) all cases (expression: case_id) in this process.

SIGNAL syntax:

SELECT
COUNT(case_id)
FROM THIS_PROCESS

Query result: The total number of cases, displayed in a Value widget.

SAP Signavio Analytics Language Guide


Tutorial PUBLIC 213
Example 2: How many different cities are involved in this process?

Learning success: Count the distinct records of a case attribute.

Query instruction: Count (keyword: COUNT) all cities (expression: City) in this process. Unlike example 1, only
distinct (keyword: DISTINCT) records are counted.

SIGNAL syntax:

SELECT
COUNT(DISTINCT City)
FROM THIS_PROCESS

Query result: The total number of distinct cities, displayed in a Value widget:

SAP Signavio Analytics Language Guide


214 PUBLIC Tutorial
Example 3: How many cases exist for each city?

Learning success:

• Count two or more case attributes.


• Rename case attribute names with alias names.
• Sort the result set.

Query instruction: Count (keyword: COUNT) the number of cases (expression: case id) by city (expression:
City). Rename the case attribute names with aliases (keyword: AS) to "Case Number" and "Site". This makes
labels for widgets easier to understand. Finally sort the result set by Case numbers (keywords: ORDER BY 1) in
descending order (keyword: DESC).

The order expression 1 selects the column, which has to be sorted. You can sort in ascending order (keyword:
ASC), descending order (keyword: DESC), by null values first (keyword: NULLS FIRST,) or by null values last
(keyword: NULLS LAST).

SIGNAL syntax:

SELECT
COUNT(case_id) AS "Case Numbers", City AS "Site"
FROM THIS_PROCESS
ORDER BY 1 DESC

Query display: The total number of cases by city, displayed in a SIGNAL table widget and in a Breakdown
widget.

Table:

SAP Signavio Analytics Language Guide


Tutorial PUBLIC 215
Breakdown (bar chart):

Example 4: How many cases exist for New York and Miami?

Learning success: Filter a result set to include only records that fulfill a specified condition.

Query instruction: This query is very similar to example 3, but in this case, you do not query all cases but only
the cases for New York and Miami. To filter the result, introduce the filter (keyword: WHERE) and specify the
filter condition (keyword: IN + expression: 'New York', 'Miami'). Sort the result set by cities (keyword: ORDER
BY 1), in descending order(keyword: DESC).

SIGNAL syntax:

SELECT
COUNT(case_id) AS "Case Numbers", "City" AS "Site"
FROM THIS_PROCESS
WHERE City IN('New York', 'Miami')
ORDER BY 1 DESC

Query display: The total number of cases by filtered cities, displayed in a SIGNAL table widget and in a
Breakdown widget.

SAP Signavio Analytics Language Guide


216 PUBLIC Tutorial
Table:

Breakdown (bar chart):

2.3 Analyze order amounts

You want to get insights about the order amount: What is the average order amount of this process? What is
the average order amount in Houston? What is the total order amount in Boston? What is the order amount in
Boston related to the total order amount?

SAP Signavio Analytics Language Guide


Tutorial PUBLIC 217
Example 1: What is the average order amount of this process?

Learning success: Determine the average value of a case attribute.

Query instruction: Determine the average value (keyword: AVG) for the order amount(expression: Order
Amount in EUR).

SIGNAL syntax:

SELECT
AVG("Order Amount in EUR")
FROM THIS_PROCESS

Query result: The aggregated value, displayed in a Value widget:

Example 2: What is the average order amount in Houston?

Learning success: Determine a filtered average case attribute.

Query instruction: Determine the average order amount (see example 1). Introduce the filter (keyword:
WHERE) and specify the filter condition (expression: "City"='Houston').

SIGNAL syntax:

SELECT
AVG("Order Amount in EUR")
FROM THIS_PROCESS
WHERE("City"='Houston')

SAP Signavio Analytics Language Guide


218 PUBLIC Tutorial
Query result: The average order amount in Houston, displayed in Value widget:

Example 3: What is the total order amount in Boston?

Learning success: Sum up a case attribute.

Query instruction: Sum up (keyword: SUM) the total order amount (expression: "Order Amount in EUR").
Introduce the filter (keyword: WHERE) and specify the filter condition (expression: "City"='Boston').

SIGNAL syntax:

SELECT
SUM("Order Amount in EUR")
FROM THIS_PROCESS
WHERE("City"='Boston')

Query result: The total order amount in Boston, displayed in a Value widget:

SAP Signavio Analytics Language Guide


Tutorial PUBLIC 219
Example 4: What is the percentage order amount in Boston compared to the
total order amount?

Learning success:

• Determine the percentage value of a case attribute compared to the overall value.
• Apply filter condition(s) within a query.

Query instruction: Sum up the order amount in Boston (see example 3). Unlike example 3, you cannot
apply the filter condition as the last step. You have to filter (keyword: FILTER + filter condition: (WHERE
"City"='Boston')) the result set before you can calculate the percentage value.

SIGNAL syntax:

SELECT
SUM("Order Amount in EUR")
FILTER (WHERE "City"='Boston')
/SUM("Order Amount in EUR")
* 100
FROM THIS_PROCESS

Query result: The percentage order amount of Boston, displayed in a Value widget:

2.4 Determine case cycle times

Read about how cycle times are determined in the SIGNAL tutorial.

You want to determine the cycle times of your process: How long is the average cycle time of all cases? How
long is the average cycle time by city? What are the maximum / minimum cycle times by city?

SAP Signavio Analytics Language Guide


220 PUBLIC Tutorial
Example 1: How long is the average cycle time of all cases?

Learning success:

• Calculate cycle times


• Perform subqueries on event attributes

Query instruction: You have to calculate the cycle times first and then aggregate them to an average value. The
cycle times are calculated from the event-based timestamps, so you have to perform a subquery (keyword:
(SELECT).

To calculate the cycle time, you have to subtract the first event timestamp (keyword: SELECT FIRST +
expression: end_time) from the last event timestamp (keyword: SELECT LAST + expression: end_time). From
these values, you aggregate the average value (keyword: AVG) .

SIGNAL syntax:

SELECT
AVG(
(SELECT LAST(end_time))
-
(SELECT FIRST(end_time)))
FROM THIS_PROCESS

Query result: The average cycle time, displayed in a Value widget:

Example 2: How long is the average cycle time by city?

Learning success: Determine cycle time by case attribute.

Query instruction: Determine the average cycle time (see example 1) by city (expression: City). Rename the
case attribute with an alias (keyword: AS) to "Cycle Time".

SIGNAL syntax:

SELECT
AVG(
(SELECT LAST(end_time))
-
(SELECT FIRST(end_time))) AS "Cycle Time", "City"

SAP Signavio Analytics Language Guide


Tutorial PUBLIC 221
FROM THIS_PROCESS

Query result: The average cycle times by city, displayed in a SIGNAL table widget:

Example 3: What are the maximum / minimum cycle times by city?

Learning success: Calculate the largest / smallest values.

Query instruction: According to example 1, you calculate the cycle times by city. From these values, you
determine the smallest value(keyword: MIN) and the largest values(keyword: MAX). Rename the values with
aliases (keyword: AS) to "Maximum Cycle Time" and "Minimum Cycle Time". Finally sort the result set by
city(keywords: ORDER BY 3) in ascending order(keyword: ASC).

SIGNAL syntax:

SELECT
MAX(
(SELECT LAST(end_time))
-
(SELECT FIRST(end_time))) AS "Maximum Cycle Time",
MIN(
SELECT LAST(end_time))
-
(SELECT FIRST(end_time))) AS "Minimum Cycle Time",
"City"
FROM THIS_PROCESS
ORDER BY 3 ASC

SAP Signavio Analytics Language Guide


222 PUBLIC Tutorial
Query result: The maximum /minimum cycle times, displayed in a SIGNAL table widget:

2.5 Investigate events

Read about how events of the process are used in the SIGNAL tutorial.

You want to get an overview about the events of the process: How many cases have been closed / canceled?
What is the drop-out rate? How many cases follow the standard process? How many cases are canceled
although the T-shirt has been sent for printing?

Example 1: How many cases have been closed / canceled?

Learning success: Counting the total number of events.

You perform two subqueries for the last event names and sum up all cases for which the respective condition is
fulfilled. The event names are event-based attributes, so you perform a subquery (keyword: (SELECT).

Select the last events of the cases (keyword: SELECT LAST + expression: event_name).

If (keyword: IF) the last event name is "Receive Delivery Confirmation" (keyword: IN + expression: ('Receive
Delivery Confirmation')) count 1, otherwise 0 (keyword: 1,0)). Sum up (keyword: SUM) the value for all cases.
Rename the value with an alias(keyword: AS) to "Closed Cases".

SAP Signavio Analytics Language Guide


Tutorial PUBLIC 223
To count the value for the canceled cases, reverse the count condition (keyword: 0,1). Rename the column
header with an alias (keyword: AS) to "Canceled Cases".

SIGNAL syntax:

SELECT
SUM
(IF
((SELECT LAST("event_name"))
IN('Receive Delivery Confirmation'),1,0)) AS "Closed Cases",
SUM
(IF
((SELECT LAST("event_name"))
IN('Receive Delivery Confirmation'),0,1)) AS "Canceled Cases"
FROM THIS_PROCESS

Query result: The total number of closed and canceled cases, displayed in a SIGNAL table widget:

Example 2: What is the drop-out rate?

Learning success: Filter for not true conditions.

Query instruction: Select the last events of the cases (keyword: SELECT LAST + expression: event_name).
Filter the result set(keyword: FILTER (WHERE) for event names other than (keyword: NOT) "Receive Delivery
Confirmation" (keyword: IN+ expression: ('Receive Delivery Confirmation')) and calculate the percentage.

SIGNAL syntax:

SELECT
(COUNT(case_id) FILTER
(WHERE NOT(SELECT LAST(event_name)
IN('Receive Delivery Confirmation'))))
/
COUNT(case_id)
*100
FROM THIS_PROCESS

SAP Signavio Analytics Language Guide


224 PUBLIC Tutorial
Query results: The drop-out rate, displayed in a Value widget:

Example 3: How many cases follow the standard process?

Learning success: Determine the process conformance.

Query instruction: This query is similar to example 2, but in this case, you do not only search for the first or last
event but for a certain pattern of events.

You query the following pattern:

1. The starting event is "Receive Customer Order" (expression: ^'Receive Customer Order')
2. The next event (directly or indirectly following the start event) is "Receive Payment" (expression: ~>
'Receive Payment').
3. The next event (directly or indirectly following the preceding event) is either "Ship Goods Standard" or
"Ship Goods Express"(expression: ~>('Ship Goods Standard | 'Ship Goods Express')) .
4. The final event (directly or indirectly following the preceding event) is "Receive Delivery Confirmation"
(expression: 'Receive Delivery Confirmation'$).

For the conformance to this pattern, you calculate the percentage.

SIGNAL syntax:

SELECT
(COUNT(case_id) FILTER
(WHERE event_name MATCHES
(^ 'Receive Customer Order'
~>'Receive Payment'
~>('Ship Goods Standard'|'Ship Goods Express')
~> 'Receive Delivery Confirmation'$)))
/
COUNT(case_id)
*100
FROM THIS_PROCESS

Query result: The pattern matching, displayed in a Value widget.

SAP Signavio Analytics Language Guide


Tutorial PUBLIC 225
Example 4: How many cases are canceled although T-shirt has been sent for
printing?

Learning success: Determine the process conformance.

Query instruction: This query is similar to example 3, but for a different type of pattern: You want to determine
how many orders have been canceled while the T-Shirt has already been sent for printing.

You query the following pattern:

1. The starting event is "Receive Customer Order"(expression: ^'Receive Customer Order')


2. The next event (directly or indirectly following the start event) is "Receive Payment"(expression: ~>
'Receive Payment').
3. The next event (directly or indirectly following the preceding event) is "Send T-shirt to Printing"(expression:
~>'Ship T-shirt to Printing') .
4. The final event (directly or indirectly following the preceding event) is "Order Canceled"(expression: 'Order
Canceled'$).

For the conformance to this pattern, you calculate the percentage.

SIGNAL syntax:

SELECT
(COUNT(case_id) FILTER
(WHERE event_name MATCHES
(^ 'Receive Customer Order'
~>'Receive Payment'
~>'Send T-shirt to Printing')
~>'Order Canceled'$)))
/
COUNT(case_id)
*100
FROM THIS_PROCESS

Query result: The pattern matching, displayed in a Value widget.

SAP Signavio Analytics Language Guide


226 PUBLIC Tutorial
SAP Signavio Analytics Language Guide
Tutorial PUBLIC 227
3 SIGNAL Cookbook

What is the cookbook, who is it for and what will they get out of it?

Audience

The intended audience of the cookbook is process analysts who already have a basic familiarity with SIGNAL
and knowledge of similar querying languages, like SQL. We recommend that the reader already knows the core
keywords and functions available, and has already used the language to construct simple queries.

Purpose

SIGNAL, the SAP Signavio Analytics Language, is the process mining query language of SAP Signavio Process
Intelligence. It's a powerful tool with numerous features that can be used and combined in many different ways.
This cookbook aims to guide early-stage users who already have some basic familiarity with SIGNAL and help
them to develop their abilities with the language.

Structure

The cookbook's approach is to guide the reader through a series of examples of process analysis using
SIGNAL. You can think of each example as a use case or recipe demonstrating how to use the language to
achieve some nontrivial goal.

They're organized into categories corresponding to typical process analysis activities, such as determining
conformance, variants, or rework. This way, you can use the cookbook not only as a learning resource but also
a reference guide, one that you can browse in order to learn about achieving specific, commonly occurring
goals.

3.1 Cycle Time

Learn about different ways of calculating cycle times from your process data.

Cycle time refers to the recorded time between two events in a case. By itself, cycle time generally refers to the
duration of a whole case, namely the time between that cases's first and last events. However, cycle time can
also refer to the duration between two arbitary events of interest to the user.

SAP Signavio Analytics Language Guide


228 PUBLIC SIGNAL Cookbook
3.1.1 Average Cycle Time

Calculate the average cycle time in a process.

Goal

Discover how long it takes on average to execute a process.

Solution

Calculate the complete cycle time for all cases and then find the average value from this collection.

Discussion

Every event has an associated end_date value. We can locate the earliest event in a case by using the FIRST
function, which returns the first element in a collection.

FIRST(end_date)

Similarly, we can locate the latest event in a case using the LAST function.

To calculate the duration of a case, subtract the earliest event_time from the latest event_time. Keep in
mind that event_time is an event-level attribute, so this subtraction is done in a subquery.

(SELECT LAST(end_time) - FIRST(end_time))

This expression would return the cycle times of all cases. To calculate the average of all these values, supply the
expression as input to the AVG function.

AVG( (SELECT LAST(end_time) - FIRST(end_time)) )

We can now complete the query.

SELECT AVG( (SELECT LAST(end_time) - FIRST(end_time)) ) AS "Average Cycle Time"


FROM THIS_PROCESS

SAP Signavio Analytics Language Guide


SIGNAL Cookbook PUBLIC 229
Example Output

Related Information

AVG [page 88]


FIRST [page 93]
LAST [page 94]

3.1.2 Cycle Time Between Events

Calculate the cycle times between all consecutive events in a case.

Goal

Discover how long each step of a case took. In other words, we want to know the cycle times between each pair
of consecutive events.

Solution

For each case, order the events chronologically and compare the timestamp of each event to its predecessor
(where it has one).

SAP Signavio Analytics Language Guide


230 PUBLIC SIGNAL Cookbook
Discussion

To get the timestamp of the current row, we can select its end_date attribute.

As part of the solution, we want to compare each row and its immediate neighbor. For comparing a row and its
predecessor, the LAG window function is available.

 Tip

Window functions allow you to group your data into partitions and carry out operations within that
partition. You can use a window function to perform calculations on the set of rows in the same partition as
the current row.

The LAG function accesses a column value from the row preceding the current row. Selecting LAG(end_time)
returns the timestamp of the previous row. Bear in mind that the first row in each partition has no predecessor,
in which case LAG returns NULL.

Additionally, we need to configure two things in LAG function:

1. The partition. We're examining all events on a per-case basis, so we partition by case_id.
2. The sorting. We need the events in chronological order, so we sort by end_time.

This gives us the complete form:

LAG(end_time) OVER (PARTITION BY case_id ORDER BY end_time)

To get the cycle time between the two consecutive events, we can subtract the timestamp of the previous
(earlier) row from that of the current one.

end_time - LAG(end_time) OVER (PARTITION BY case_id ORDER BY end_time)

Selecting this alone would give us only a list of durations. Let's also associate each duration with the names of
the two enclosing events. We can get the event name of the current event by selecting event_name.

To get the name of a previous event, we can again use LAG. We partition and order the rows in the same way as
before, but instead select the event_name.

LAG(event_name) OVER (PARTITION BY case_id ORDER BY end_time)

We have now defined the columns of our result set, which we can select along with the case_id:

SELECT
case_id,
LAG(event_name) OVER (PARTITION BY case_id ORDER BY end_time) AS Predecessor,
event_name AS Event,
end_time - LAG(end_time) OVER (PARTITION BY case_id ORDER BY end_time) AS
cycle_time

All that remains is to add a FROM clause. Keep in mind that window functions can't work with nested data, so
the process data table must be flattened.

SELECT
case_id,
LAG(event_name) OVER (PARTITION BY case_id ORDER BY end_time) AS Predecessor,
event_name AS Event,
end_time - LAG(end_time) OVER (PARTITION BY case_id ORDER BY end_time) AS
cycle_time

SAP Signavio Analytics Language Guide


SIGNAL Cookbook PUBLIC 231
FROM FLATTEN(THIS_PROCESS)

Example Output

Given this example input data

our query returns the following output:

SAP Signavio Analytics Language Guide


232 PUBLIC SIGNAL Cookbook
Related Information

LAG [page 186]


Window Functions [page 167]

3.2 Variants

Learn about the different ways of analyzing variants in a process.

A process variant is a unique sequence of recorded events in a process.

3.2.1 Top N Variants

Show an arbitrary number of variants ranked according to their prevalence.

Goal

Determine which variants are the most prevalent within the process data. We'd like to choose how many
variants to see and also query other data associated with each variant, in this case the average cycle time.

Solution

Find which distinct sequences of events exist in the process data, count them, and order the result numerically.
Also, for each distinct sequence, calculate its average cycle time.

Discussion

As specified by the data model, each case contains a nested table of event data. One of the columns of this
nested table is event_name. Selecting event_name in a query therefore returns a list of event names.

SELECT case_id, event_name AS "Variant"


FROM THIS_PROCESS

Examples of such variants might be as follows:

SAP Signavio Analytics Language Guide


SIGNAL Cookbook PUBLIC 233
case_id Variant

00001 • Receive Customer Order


• Receive Payment
• Ship Goods Standard
• Receive Delivery Confirmation

00002 • Receive Customer Order


• Receive Payment
• Ship Goods Standard
• Receive Delivery Confirmation

00003 • Receive Customer Order


• Receive Payment
• Ship Goods Express
• Receive Delivery Confirmation

Although this example contains three event sequences, there are only two distinct sequences – notice how
the first two cases ship goods standard, while the third case ships goods express. To show only the distinct
variants, you can group them by their sequence of event names.

SELECT event_name AS "Variant"


FROM THIS_PROCESS
GROUP BY 1

To count the number of distinct variants in this grouped data set, apply COUNT to a case-level attribute.

SELECT
event_name AS "Variant",
COUNT(case_id)
FROM THIS_PROCESS
GROUP BY 1

To rank the variants starting with the most prevalent, sort this column in descending order of value. To choose
only the most prevalent N values, limit the result set to N.

SELECT
event_name AS "Variant",
COUNT(case_id)
FROM THIS_PROCESS
GROUP BY 1
ORDER BY 2 DESC
LIMIT 5

Finally, we want to find the average cycle time per variant, which is explained in the Average Cycle Time recipe.

AVG( SELECT LAST(end_time) - FIRST(end_time) )

AVG is an aggregate function. When used with a GROUP BY clause, an aggregate function computes values
across all rows of each group and returns a separate value for each group. Since we're grouping by sequence of
event names, this calculates the average of each distinct variant.

We can now complete the query.

SELECT event_name AS "Variant",


COUNT(case_id) as "Case Count",

SAP Signavio Analytics Language Guide


234 PUBLIC SIGNAL Cookbook
AVG( (SELECT LAST(end_time) - FIRST(end_time)) ) AS "Average Cycle Time"
FROM THIS_PROCESS
GROUP BY 1
ORDER BY 2 DESC
LIMIT 5

Example Output

SAP Signavio Analytics Language Guide


SIGNAL Cookbook PUBLIC 235
Related Information

Average Cycle Time [page 229]


AVG [page 88]
COUNT [page 91]
Data Model [page 4]
GROUP BY Clause [page 24]
LIMIT Clause [page 35]
ORDER BY Clause [page 26]

3.3 Rework and Repeated Events

Learn about different ways of analyzing rework in a process.

Rework within a case is identified by a number of repeated process steps exceeding a given threshold.

3.3.1 Cases With More Than N Repeated Events

Show an arbitrary number of cases containing rework, treating the threshold value of rework as a parameter.

Goal

Identify cases containing an amount rework that exceeds a given threshold.

Solution

In each case, count the number of occurrences of each event. Specify the minimum number of event
occurrences to qualify them as rework and filter out cases whose value is insufficient.

SAP Signavio Analytics Language Guide


236 PUBLIC SIGNAL Cookbook
Discussion

To count occurrences of events, we can use the OCCURRENCE function. This function calculates a running total
of occurrences for a specified event-level attribute. For example, consider a case with the following list of event
names:

case_id event_name

00017 Receive Customer Order

Change Order Quantity

Change Order Quantity

Change Order Quantity

Receive Payment

Ship Goods Standard

Ship Goods Standard

Receive Delivery Confirmation

The OCCURRENCE function would return the following values for event_name: [1, 1, 2, 3, 1, 1, 2, 1]. These values
show that each event occurs between one and three times in that case.

Because our goal is to include only cases above the threshold value, let's use the OCCURRENCE function as part
of a WHERE clause. Let's choose 3 as the threshold value. Since we're operating at event level, the clause must
use an event-level subquery. However, we can't simply use the OCCURRENCE function like so:

SELECT case_id, "event_name", "end_time"


FROM THIS_PROCESS
WHERE (SELECT OCCURRENCE(event_name) AS occ) > 3

That's because a subquery must return an aggregated value instead of a collection of values. Since our goal is
to identify cases meeting a minimum threshold value, let's take the maximum number of occurrences by using
the MAX function. Doing this determines if at least one event meets the threshold.

SELECT case_id, "event_name", "end_time"


FROM THIS_PROCESS
WHERE (
SELECT MAX(occ) FROM (
SELECT OCCURRENCE(event_name) AS occ)
AS sub) > 3

Finally, we can arbitrarily limit the number of cases returned. Let's take the first 10 cases from the process
data.

SELECT case_id, "event_name", "end_time"


FROM THIS_PROCESS
WHERE (
SELECT MAX(occ) FROM (
SELECT OCCURRENCE(event_name) AS occ)
AS sub) > 3
ORDER BY 1
LIMIT 10

SAP Signavio Analytics Language Guide


SIGNAL Cookbook PUBLIC 237
Example Output

(The subsequent seven cases are not depicted.)

Related Information

MAX [page 95]


OCCURRENCE [page 189]
WHERE Clause [page 16]

SAP Signavio Analytics Language Guide


238 PUBLIC SIGNAL Cookbook
3.4 Compliance

See examples of analyzing compliance in a process.

Compliance measures to what extent a process exhibits specific patterns and behaviors.

3.4.1 Compliance Rate for a Subset of Cases

Show the compliance rate for only a subset of cases you're interested in. As a demonstration, we'll consider the
subset as sales orders using standard invoicing.

Goal

See what rate of cases receive payment when standard invoicing is applied.

Solution

Calculate a count of cases exhibiting a specific pattern of events, then divide this by the total number of cases.
In this instance, a case is counted if it uses standard invoicing and has received payment.

Discussion

To count cases, we can use the COUNT function. However, this counts all cases, so we need to exclude cases
whose events don't follow the event pattern we're interested in.

We can exclude cases from a count by applying the FILTER clause to the COUNT function. This clause has the
following syntax:

FILTER (WHERE <condition>)

So, we need to express behavior as a condition. For this, SIGNAL provides matching expressions. These yield
true or false depending on whether event-level attributes follow a specific sequence. In this example, we're
interested in cases following the standard invoicing pattern: a customer order is received and payment follows
later, either directly or indirectly. In our example data, this information is captured in the event name. We can
express this as:

event_name MATCHES ('Receive Customer Order' ~> 'Receive Payment')

SAP Signavio Analytics Language Guide


SIGNAL Cookbook PUBLIC 239
This becomes the condition in the FILTER clause. Putting this together with the COUNT function gives:

COUNT(1) FILTER (WHERE event_name MATCHES ('Receive Customer Order' ~> 'Receive
Payment'))

Since we'd like the compliance rate, we divide the filtered number of cases by the total number of cases and
multiply by 100.

(
COUNT(1) FILTER (WHERE event_name MATCHES ('Receive Customer Order'~>
'Receive Payment'))
/
COUNT(1)
) * 100

Finally, we form this as a query.

SELECT
(
COUNT(1) FILTER (WHERE event_name MATCHES ('Receive Customer Order'~>
'Receive Payment'))
/
COUNT(1)
) * 100 AS "Standard Invoicing Compliance Rate"
FROM THIS_PROCESS

Related Information

COUNT [page 91]


FILTER Clause [page 18]
Matching Expressions [page 62]

3.5 Pattern Matching and Deviations

Learn how you can specify behaviour patterns, using them to find matches or deviations in process data.

A behaviour is an expression evaluating case or event level attributes and can be used in a pattern matching
expression.

SAP Signavio Analytics Language Guide


240 PUBLIC SIGNAL Cookbook
3.5.1 Incomplete Cases

Find the number of cases whose behavior shows them to be incomplete. As a demonstration, we'll consider
sales invoices, which are considered incomplete if they remain unpaid and haven't been cancelled..

Goal

Obtain a count of how many invoices remain unpaid and aren't in any other way resolved.

Solution

Find all cases where an order was received but no payment followed, ignoring cancelled orders. Count the
resultant cases.

Discussion

In our example process data, receipt of an order is given the event name 'Receive Customer Order'. Using
pattern matching, we can identify all received orders by matching against this event name

event_name MATCHES ('Receive Customer Order')

We need to refine the matching so that, from these cases, only those which are either unpaid or not canceled
are matched. In the case of unpaid orders, receipt events aren't followed by payment events, either directly or
indirectly.

NOT event_name MATCHES ('Receive Customer Order' ~> 'Receive Payment')

Similarly, in the case of non-canceled orders, receipt events aren't followed by cancellation events, either
directly or indirectly.

NOT event_name MATCHES ('Receive Customer Order' ~> 'Cancel Invoice')

For an order to be considered incomplete, the sequence of events in each case must match all three of these
conditions. Therefore, we connect them using the logical connector AND.

event_name MATCHES ('Receive Customer Order')


AND
NOT event_name MATCHES ('Receive Customer Order' ~> 'Receive Payment')
AND
NOT event_name MATCHES ('Receive Customer Order' ~> 'Cancel Invoice')

Finally, this matching expression can become part of a WHERE clause. Because we're counting matches, we
can simply count the number of rows that match that expression.

SELECT COUNT(1) AS "Case Count"

SAP Signavio Analytics Language Guide


SIGNAL Cookbook PUBLIC 241
FROM THIS_PROCESS
WHERE
event_name MATCHES ('Receive Customer Order')
AND
NOT event_name MATCHES ('Receive Customer Order' ~> 'Receive Payment')
AND
NOT event_name MATCHES ('Receive Customer Order' ~> 'Cancel Invoice')

Related Information

COUNT [page 91]


Logical Expressions [page 58]
Matching Expressions [page 62]

3.6 Time Series

See examples of analyzing time series process data.

A time series arranges process data into chronologically ordered cases and events.

3.6.1 Filtered Events With Gaps Filled

Filter events to find specific cases of interest and order them chronologically without leaving any gaps in the
time series.

Goal

Identify cases containing a specific pattern of events and put them into a time series, summarizing them at a
particular level of precision. To demonstrate this, we'll write a query that selects only sales orders paid for in
multiple installments and counts them on a per day basis.

Solution

Select the timestamps of the cases in the process data, filtering for cases whose event patterns contain more
than one payment event. Summarize them per day and fill any gaps in the time series, so that days without
such cases are also included in the result set.

SAP Signavio Analytics Language Guide


242 PUBLIC SIGNAL Cookbook
Discussion

First, select the timestamp. Take the date of the case's first event, in other words when the order was created.
Since we're selecting an event, use an event-level subquery.

(SELECT FIRST(end_time))

The timestamps are to be summarized per day, so truncate the timestamp to that level of precision.

DATE_TRUNC(
'day',
(SELECT FIRST(end_time))
) AS "Date"

To count cases per day, use the COUNT function to count case_id in the result set. (Recall that when the
SELECT clause includes both aggregate and non-aggregate expressions, the result is automatically grouped by
the non-aggregate expressions, in this case the timestamp.)

Also, order the result set chronologically.

SELECT
DATE_TRUNC(
'day',
(SELECT FIRST(end_time))
) AS "Date",
COUNT(case_id) AS "# Cases"
FROM THIS_PROCESS
ORDER BY 1

At this stage, the query counts all cases and returns the following result on the example data:

To include only the cases where multiple payments were made, filter using a matching expresion. Include only
cases where a payment event was followed at some point by another payment event.

SELECT
DATE_TRUNC(
'day',

SAP Signavio Analytics Language Guide


SIGNAL Cookbook PUBLIC 243
(SELECT FIRST(end_time))
) AS "Date",
COUNT(case_id) AS "# Cases"
FROM THIS_PROCESS
WHERE event_name MATCHES ('Receive Payment' ~> 'Receive Payment')
ORDER BY 1

Now that the query filters out certain cases, executing it on the example data leaves gaps in the time series:

To remove the gaps, use the FILL clause to insert rows where dates are missing. The query selects two
columns, so the FILL clause must provide one specification for each:

1. TIMESERIES('day'): The first column of an inserted row is filled with the day missing at that point in the
time series.
2. NULL: The second column of an inserted row is filled with NULL.

Adding the FILL clause puts NULL into the gaps:

SELECT
DATE_TRUNC(
'day',
(SELECT FIRST(end_time))
) AS "Date",
COUNT(case_id) AS "# Cases"
FROM THIS_PROCESS
WHERE event_name MATCHES ('Receive Payment' ~> 'Receive Payment')
ORDER BY 1
FILL TIMESERIES ('day'), NULL

SAP Signavio Analytics Language Guide


244 PUBLIC SIGNAL Cookbook
Finally, to fill the gaps with zeroes instead – so, for example, the result can be plotted suitably on a chart – use
the COALESCE function to replace any NULL values in the result set.

SELECT "Date", COALESCE("# Cases", 0) AS "# Cases"


FROM (
SELECT
DATE_TRUNC(
'day',
(SELECT FIRST(end_time))
) AS "Date",
COUNT(case_id) AS "# Cases"
FROM THIS_PROCESS
WHERE event_name MATCHES ('Receive Payment' ~> 'Receive Payment')
ORDER BY 1
FILL TIMESERIES ('day'), NULL
) AS sub

SAP Signavio Analytics Language Guide


SIGNAL Cookbook PUBLIC 245
Example Output

Related Information

COALESCE [page 109]


DATE_TRUNC [page 132]
FILL Clause [page 28]
Matching Expressions [page 62]

3.6.2 Active Cases Within a Period

Obtain a summary of active cases over time.

Goal

See a month-by-month overview of how many cases were active in the respective time period. Also, we'd like
running totals of the number of started and finished cases.

SAP Signavio Analytics Language Guide


246 PUBLIC SIGNAL Cookbook
Solution

The solution has three parts:

1. On a monthly basis, find which cases were opened and which were closed.
2. Count the found cases, filling any gaps in time series.
3. Calculate from these figures how many cases were active.

Discussion

Identifying Opened and Closed Cases


First, identify for each case the dates when the order was opened and when it was closed.

SELECT (SELECT FIRST(end_time)) AS "Month"


FROM THIS_PROCESS
SELECT (SELECT LAST(end_time)) AS "Month"
FROM THIS_PROCESS

We're interested in a month-by-month overview, so let's truncate the precision of the dates to the level of
month.

SELECT DATE_TRUNC('month', (SELECT FIRST(end_time))) AS "Month"


FROM THIS_PROCESS
SELECT DATE_TRUNC('month', (SELECT LAST(end_time))) AS "Month"
FROM THIS_PROCESS

Next, we label each selected row with a number. This label, started, indicates if the row records an order
being opened (1) or closed (0).

SELECT DATE_TRUNC('month', (SELECT FIRST(end_time))) AS "Month",


1 AS started
FROM THIS_PROCESS
SELECT DATE_TRUNC('month', (SELECT LAST(end_time))) AS "Month",
0 AS started
FROM THIS_PROCESS

Finally, join these two queries using the UNION ALL clause so that they return one combined result set.

SELECT DATE_TRUNC('month', (SELECT FIRST(end_time))) AS "Month",


1 AS started
FROM THIS_PROCESS
UNION ALL
SELECT DATE_TRUNC('month', (SELECT LAST(end_time))) AS "Month",
0 AS started
FROM THIS_PROCESS

This query serves as a subquery, providing a data source for an outer query that we construct in the following
section.

Counting the Cases per Month


Let's start by selecting from that result set the month, which we also use to group the data.

SELECT "Month"

SAP Signavio Analytics Language Guide


SIGNAL Cookbook PUBLIC 247
FROM (
-- The subquery from the previous section goes here.
) AS sub1
GROUP BY 1

Next, the labels we created become useful. We use them to count how many cases were opened (started =
1) and how many were closed (started = 0) by filtering on those labels before counting.

SELECT "Month",
COUNT(1) FILTER (WHERE started = 1) AS count_started,
COUNT(1) FILTER (WHERE started = 0) AS count_finished
FROM (
-- The subquery from the previous section goes here.
) AS sub1
GROUP BY 1

If a time period happens to contain no rows, it appears as a gap in the time series. It's a good idea therefore
to use a FILL clause, which inserts missing periods into any gaps. In this case, we're querying at the level of
months, so we'll use a specification of FILL TIMESTAMP('month') to ensure the regularity of the time series.

SELECT "Month",
COUNT(1) FILTER (WHERE started = 1) AS count_started,
COUNT(1) FILTER (WHERE started = 0) AS count_finished
FROM (
-- The subquery from the previous section goes here.
) AS sub1
GROUP BY 1
FILL TIMESERIES('month')

At this point, running the query produces an output something like this:

Once again, this query will become a subquery, acting as a data source for an outer query that we'll construct in
the following section.

SAP Signavio Analytics Language Guide


248 PUBLIC SIGNAL Cookbook
Calculating Active Cases
Let's begin our new outer query by selecting the month and the two count columns from the previous query.
Doing this gives us two of the three columns stated in our original goal.

SELECT "Month",
count_started AS "Started, Current & Previous Months",
count_finished AS "Completed, Current & Previous Months",
FROM (
-- Subquery from the previous section goes here.
) AS sub2
) AS sub3

The third column should display the number of active cases for a particular month in time. For any given
month, that number is calculated by taking the number of cases started up to that month and subtracting the
cases finished up to the previous month. Whenever you need to consider the values from the row immediately
before, you can use the LAG function.

The following expression performs the desired calculation:

count_started - LAG(count_finished) OVER (ORDER BY "Month")

Be mindful that if no previous row exists, LAG returns NULL. So, we use the COALESCE function to ensure that a
numeric value is returned in such a case.

count_started - COALESCE(LAG(count_finished) OVER (ORDER BY "Month"), 0)

We can add this to our SELECT clause as the "Active Cases" column.

SELECT "Month",
count_started AS "Started, Current & Previous Months",
count_finished AS "Completed, Current & Previous Months",
count_started - COALESCE(LAG(count_finished) OVER (ORDER BY "Month"), 0) AS
"Active Cases"
FROM (
-- Subquery from previous section goes here.
) AS sub2
) AS sub3

Putting It All Together


Our final query therefore looks like this:

SELECT "Month",
count_started AS "Started, Current & Previous Months",
count_finished AS "Completed, Current & Previous Months",
count_started - COALESCE(LAG(count_finished) OVER (ORDER BY "Month"), 0) AS
"Active Cases"
FROM (
SELECT "Month",
SUM(count_started) OVER (ORDER BY "Month") AS count_started,
SUM(count_finished) OVER (ORDER BY "Month") AS count_finished
FROM (
SELECT "Month",
COUNT(1) FILTER (WHERE started = 1) AS count_started,
COUNT(1) FILTER (WHERE started = 0) AS count_finished
FROM (
SELECT DATE_TRUNC('month', (SELECT FIRST(end_time))) AS "Month",
1 AS started
FROM THIS_PROCESS
UNION ALL
SELECT DATE_TRUNC('month', (SELECT LAST(end_time))) AS "Month",

SAP Signavio Analytics Language Guide


SIGNAL Cookbook PUBLIC 249
0 AS started
FROM THIS_PROCESS
) AS sub1
GROUP BY 1
FILL TIMESERIES('month')
) AS sub2
) AS sub3

Example Output

Related Information

COALESCE [page 109]


COUNT [page 91]
DATE_TRUNC [page 132]
FILL Clause [page 28]
FILTER Clause [page 18]
FIRST [page 93]
LAG [page 186]
LAST [page 94]
UNION ALL Clause [page 41]

SAP Signavio Analytics Language Guide


250 PUBLIC SIGNAL Cookbook
Important Disclaimers and Legal Information

Hyperlinks
Some links are classified by an icon and/or a mouseover text. These links provide additional information.
About the icons:

• Links with the icon : You are entering a Web site that is not hosted by SAP. By using such links, you agree (unless expressly stated otherwise in your
agreements with SAP) to this:

• The content of the linked-to site is not SAP documentation. You may not infer any product claims against SAP based on this information.

• SAP does not agree or disagree with the content on the linked-to site, nor does SAP warrant the availability and correctness. SAP shall not be liable for any
damages caused by the use of such content unless damages have been caused by SAP's gross negligence or willful misconduct.

• Links with the icon : You are leaving the documentation for that particular SAP product or service and are entering an SAP-hosted Web site. By using
such links, you agree that (unless expressly stated otherwise in your agreements with SAP) you may not infer any product claims against SAP based on this
information.

Videos Hosted on External Platforms


Some videos may point to third-party video hosting platforms. SAP cannot guarantee the future availability of videos stored on these platforms. Furthermore, any
advertisements or other content hosted on these platforms (for example, suggested videos or by navigating to other videos hosted on the same site), are not within
the control or responsibility of SAP.

Beta and Other Experimental Features


Experimental features are not part of the officially delivered scope that SAP guarantees for future releases. This means that experimental features may be changed by
SAP at any time for any reason without notice. Experimental features are not for productive use. You may not demonstrate, test, examine, evaluate or otherwise use
the experimental features in a live operating environment or with data that has not been sufficiently backed up.
The purpose of experimental features is to get feedback early on, allowing customers and partners to influence the future product accordingly. By providing your
feedback (e.g. in the SAP Community), you accept that intellectual property rights of the contributions or derivative works shall remain the exclusive property of SAP.

Example Code
Any software coding and/or code snippets are examples. They are not for productive use. The example code is only intended to better explain and visualize the syntax
and phrasing rules. SAP does not warrant the correctness and completeness of the example code. SAP shall not be liable for errors or damages caused by the use of
example code unless damages have been caused by SAP's gross negligence or willful misconduct.

Bias-Free Language
SAP supports a culture of diversity and inclusion. Whenever possible, we use unbiased language in our documentation to refer to people of all cultures, ethnicities,
genders, and abilities.

SAP Signavio Analytics Language Guide


Important Disclaimers and Legal Information PUBLIC 251
www.sap.com/contactsap

© 2024 SAP SE or an SAP affiliate company. All rights reserved.

No part of this publication may be reproduced or transmitted in any form


or for any purpose without the express permission of SAP SE or an SAP
affiliate company. The information contained herein may be changed
without prior notice.

Some software products marketed by SAP SE and its distributors


contain proprietary software components of other software vendors.
National product specifications may vary.

These materials are provided by SAP SE or an SAP affiliate company for


informational purposes only, without representation or warranty of any
kind, and SAP or its affiliated companies shall not be liable for errors or
omissions with respect to the materials. The only warranties for SAP or
SAP affiliate company products and services are those that are set forth
in the express warranty statements accompanying such products and
services, if any. Nothing herein should be construed as constituting an
additional warranty.

SAP and other SAP products and services mentioned herein as well as
their respective logos are trademarks or registered trademarks of SAP
SE (or an SAP affiliate company) in Germany and other countries. All
other product and service names mentioned are the trademarks of their
respective companies.

Please see https://www.sap.com/about/legal/trademark.html for


additional trademark information and notices.

THE BEST RUN

You might also like