Expressions
An expression is a combination of values, variables, operators, and functions that can be evaluated to produce a result. Think of it as a sentence of instructions that we tell inorigo®, and to get an answer from these instructions we need to write it in a language that inorigo® understands, i.e., expressions.
Overview
Expressions allow you in this way to customize and transform your data from the information you have to the information that you need. They can help you reduce the need for additional attributes and enable you to, for example, apply logic, use formulas, manipulate dates, or filter items.
Where can we use expressions?
Expression can be applied in some way for most modules in inorigo®. Look for an “Expression” text box for where you can add an expression. This can for example be in attribute automation in Model Builder or calculated columns in Knowledge Set Builder.
How to use expressions
Expressions can be as simple as a single value or variable, or they can be more complex, involving multiple values, functions, and operators. Some common types of expressions include Mathematical expressions (such as 2 + 3), logical expressions (such as x > y or a == b), and string expressions (such as "Hello, " + “name”).
A good use for expressions is to manipulate the data that you have created in Model Builder in other modules such as Application Builder and Knowledge Set Builder, but you can also, to some extent, use them in Model Builder. Note that the trickiest part about learning how to use expressions will be understanding how each available function works.
We have categorized the available functions according to their use in this documentation along with descriptions on how you can apply them in expressions.
Vocabulary
Boolean
A value that is either true or false.
Double
A number with decimals, for example 22.343.
Integer
A positive or negative whole number, including 0.
Expression
A combination of variables, constants, operators, and functions that are put together in a single statement to be evaluated.
Function
Always contains $ + Function name and a start and closing parentheses (). All functions are expressions but not all expressions contain functions.
GID
Global Identifier. A way for inorigo® to identify objects.
Input
The data we give to inorigo® to process.
Null
Means that something is undefined. It has no value but note it is not equal to zero.
Output
The result we get back from inorigo® from the processing.
Operate
An action that is carried out to accomplish a given task
Inward function
A function that is enclosed within another function.
Example: $FORMAT_DATE**($GET({p0},"StartDate")**"DATE_LONG")
Outward function
The surrounding function that encloses another function.
Example: $FORMAT_DATE($GET({p0},"StartDate"), "DATE_LONG")
Operator
A character that represents a mathematical or logical action, such as +, -, = or >.
Parse
Converting information into a format. This so to make something understandable for inorigo®.
Parameter
The variable listed inside the parentheses in the function definition.
Argument
The value that are sent to the function when it is called.
Example: X=3, here the 3 is the argument and X is the parameter.
Variable
Container for storing data values.
Constant
A fixed value, for example the number 5. The value does not change and is predefined.
String
A sequence of characters, for example “Hello world”.
Substring
A string that is part of another string. "Hel" is for example a substring of "Hello World".
Syntax
The concept/rules of how different elements in an Expression should be combined in order for it to run correctly.
Zero based Index
A way of numbering in which the initial element of a sequence starts at the index 0 rather than the usual index 1.
$ Functions - Summary List
inorigo® has a number of Built-in functions, which are listed below in alphabetical order.
Name | Description |
---|---|
ABS | Calculates the absolute value of a double value. |
ACOS | Calculates the arc cosine of a number. |
ADDAY | Add days to a given date. |
ADDHOUR | Add hours to a given date. |
ADDMILLIE | Add milliseconds to a given date. |
ADDMINUTE | Add minutes to a given date. |
ADDMONTH | Add months to a given date. |
ADDSECOND | Add seconds to a given date. |
ADDWEEK | Add weeks to a given date. |
ADDYEAR | Add years to a given date. |
AGGREGATE | Performs an aggregation on a collection of items. |
ASCIITOSTRING | Returns a String object representing the specified decimal ASCII character. |
ASIN | Calculates the arc sine of a number. |
ATAN | Calculates the arc tangent of a number. |
ATINDEX | Returns the value at specified (zero-based) index of a list or array. |
AVG | Calculates the average of the given arguments. |
CALL | Executes an Inorigo Method and returns the first output of the method. |
CEIL | Calculates the smallest (closest to negative infinity) double value that is greater than or equal to the argument and is equal to a mathematical integer. |
COALESCE | Return the first non null value. |
CONTAINS | Checks if one is contained within two. |
COS | Calculates the cosine of a number. |
COSH | Calculates the hyperbolic cosine of a number. |
COT | Calculates the cotangent of a number (1/tan(n)). |
CSC | Calculates the cosecant of a number (1/sin(n)). |
DATE_LONG | Formats a timestamp according to Formats a timestamp according to DateTimeLayout.DATE_LONG format. |
format. | |
DATE*SHORT | Formats a timestamp according to DateTimeLayout.DATE_SHORT format. |
DATEADD | Adds to a given date depending on DatePart. |
DATEFORMAT | Formats a timestamp as a string. |
DATEPART | Returns the desired date part of a timestamp. |
DATETIME_LONG | Formats a timestamp according to DateTimeLayout.DATETIME_LONG format. |
DATETIME_SHORT | Formats a timestamp according to DateTimeLayout.DATETIME_SHORT format. |
DAY | Calculate the day of a date, or the current day if no date argument is passed. |
DAYNAME | Calculate the day name of a date, or the current day name if no date argument is passed. |
DEFINITIONS | Returns a list of definition IDs for one or several instances. |
DISTINCT | Performs a distinct operation on a collection of items. |
DISTINCTBYCOLUMNS | Creates a Data Set containing column matched unique rows. |
E | Calculates the double value that is closer than any other to e, the base of the natural logarithms. |
EVALUATE | The function can replace method calls and enhance performance substantially, particularly if used in a calculated column in a knowledge Set with many rows. |
EXP | Calculates Euler's number e raised to the power of a number. |
EXPR | Evaluates an expression |
FILTER | Performs a filter operation on a collection of items. |
FILTERNULL | Remove null values from a collection of items. |
FINDMANY | Returns all GlobalIDs matching the supplied criterias. |
FINDONE | Returns one GlobalID matching the supplied criterias. |
FINDSTR | Returns the index of a substring within a string. |
FLOOR | Calculates the largest (closest to positive infinity) double value that is less than or equal to the argument and is equal to a mathematical integer. |
FOREACH | Executes an expression for each item in a collection of items. |
FORMAT_DATE | Formats a timestamp as a string. |
FORMAT_NUMBER | Formats a number using the current locale. |
GET | Returns an Attribute Value. Can also be used to get a hash map value. |
GID | Creates a GlobalID. |
HOUR | Calculate the hour of a date, or the current hour if no date argument is passed. |
HTML_ENCODE | Makes a string safe to present on web. |
IFNULL | Returns second or third argument, depending on wether first argument is null. |
IIF | Returns second or third argument, depending on boolean first argument. |
IS_AUTHORIZED | Check entity for authorization. |
ISNULL | Returns wether first argument is null. |
KNOWLEDGE_SET | Executes a Knowledge Set. |
LEFT | Returns the leftmost _n* characters of a string. |
LOAD | Deprecated. |
LOG | Calculates the natural logarithm (base e) of a number. |
LOG10 | Calculates the base 10 logarithm of a number. |
LOOKUP | Performs a lookup by attribute values. |
LOOP | Executes an expression for each item in a collection of items. |
MAX | Calculates the greater double value of two numbers. |
MILLISECOND | Calculate the millisecond of a date, or the current millisecond if no date argument is passed. |
MIN | Calculates the smaller double value of two numbers. |
MINUTE | Calculate the minute of a date, or the current minute if no date argument is passed. |
MONTH | Calculate the month of a date, or the current month if no date argument is passed. |
MONTHNAME | Calculate the month name of a date, or the current month name if no date argument is passed. |
NOW | Calculates the current date and time. |
NTH | Returns the n:th object in a list or the n:th letter in a string. |
NULL | Returns null. |
OBJECT | Returns an GlobalID using the supplied identification. |
PACK | Returns a list of the arguments supplied. |
PARTNERS | Returns a list of partner Global Identifiers. |
PERCENT | Creates dataset with added percentage column(s). |
PI | Calculates the double value that is closer than any other to pi, the ratio of the circumference of a circle to its diameter. |
POW | Calculates the double value of the first number raised to the power of the second number. |
QUARTER | Calculate the quarter of a date, or the current quarter if no date argument is passed. |
QUARTERNAME | Calculate the quarter name of a date, or the current quarter name if no date argument is passed. |
REFERENTS | Returns Attribute Value referents for a given instance. |
REPLACEREGEX | The function can replace method calls and enhance performance substantially. |
REPLACESTR | Replace part(s) of a string. It is used to replace parts of a string using a regular expression. |
RIGHT | Returns the rightmost n characters of a string. |
ROUND | Rounds the first argument to the number of decimals specified by the second argument, using the HALV_EVEN rounding mode. |
SEC | Calculates the secant of a number (1/cos(n)). |
SECOND | Calculate the second of a date, or the current second if no date argument is passed. |
SELECT | Select rows and columns from a Dataset or a List of Dataset rows. |
SERIAL_NO | Generates the next serial number for the given pool. |
SIN | Calculates the sine of a number. |
SINH | Calculates the hyperbolic sine of a number. |
SIZE | Performs a size operation on a value. |
SORT | Performs sorting on a collection of items. |
SQRT | Calculates the square root of a number. |
STRING_JOIN | Returns a string built from a list of items, with specified delimiter and optional prefix and suffix |
STRINGFORMAT | Performs a string.format() operation. |
SUBCLASSES | Returns a list of subclasses. |
SUBSTR | Returns a substring of the first input string. |
SUM | Returns summary of values. |
SUPERCLASSES | Returns a list of superclasses. |
TAN | Calculates the tangent of a number. |
TANH | Calculates the hyperbolic tangent of a number. |
TIME_SHORT | Formats a timestamp according to DateTimeLayout.TIME_SHORT format. |
TIME_SHORT_MILLIES | Formats a timestamp according to DateTimeLayout.TIME_SHORT format. |
TIMESPAN | Calculates the timespan between two timestamps or a duration. |
TO_COORDINATE | Creates a valid Coordinate for use in maps. |
TOARRAY | Creates an array of the supplied input. |
TODATE | Parse argment to timestamp. |
TODATETIME | Parse argment to timestamp. |
TODOUBLE | Parse argment to double |
TOGLOBALID | Creates a GlobalID. |
TOINT | Parse argment to integer |
TOLIST | Creates a List of the supplied input. |
TOLONG | Parse argment to long |
TOLOWER | Turns a string into lower case. |
TOLOWERCASE | Turns a string into lower case. |
TOSTRING | Returns argument as its string representation. |
TOULONG | Parse argment to unsigned long (BigInteger) |
TOUPPER | Turns a string into upper case. |
TOUPPERCASE | Turns a string into upper case. |
TRANSLATE | Translates a text. |
TRIM | Removes leading and trailing spaces from a string. |
VELOCITY_IFRAME | Returns an IFRAME HTML tag for a Velocity page. |
VELOCITY_URL | Returns an URL for a Velocity page. |
WEEK | Calculate the week of a date, or the current week if no date argument is passed. |
YEAR | Calculate the year of a date, or the current year if no date argument is passed. |
YEAR_QUARTER | Calculate the year and quarter name of a date, or the current year and quarter name if no date argument is passed. |
Legacy Expression Editor
The below are relevant for the Model Builder and Application builder
Expression Editor
The Expression Editor will simplify the readability of expressions as it checks for inconsistencies and helps you with some guidance and basic validations to create the expression.
Note, the Visible option is not always available, it depends on the context expression is used, e.g. it is useful when writing expressions for map Info panel.
The Functions context menu options will show all the available Expression Functions
and they are inserted in Expression field as they are selected.
There are a few shortcuts to some of the most common operations/variables/functions used;
Ctrl-G | $GET |
Ctrl-I | @item (the Source object in map configuration) |
Ctrl-N | “name” |
Ctrl-R | @record |
Variables – Verso View will give the list of available default variables, user defined variables and dataset(s) as input to new Expression Variables in view;
Example that shows the available items defined in view
Refresh this menu
Sometimes the contents of the context menu are not updated, especially for some Variables and Datasets that require calculations to be updated, hence the Refresh option to update the list.
Expression Reference Guide
Advanced Functions
$CALL
Executes an Inorigo Method and returns the first output of the method.
Input:
String methodName , Any param1, Any param2,...
Output:
Any
Usage:
$CALL(Target Global Identifier [, method input, ...])
$CALL(Method Unique Identifier [, method input, ...])
$CALL(Method Fully Qualified Name [, method input, ...])
Example:
$call("MyChange/HelloWorld", "Hey", "You"). This will run the method "HelloWorld" in the process object "MyChange" and give "Hey" and "You" as input variables.
$Coalesce
Return the first non null value.
Input:
Object or list/collection
Output:
Any
Usage:
$COALESCE(@NULL, 1, 2, "test") → 1
Example:
We have associations of the definition Person in a filter box. The below expression will output the first non null item in the selected lis
This expression is first checking if the first selected item in p0 is null via $NTH({p0}, 0), if null, it will return "Nothing is selected in p0!" but if any value is found it will return the first non null item.
Result below. Notice how the output changes accordingly to whether if a item in a higher order is selected.
$EXPR
Evaluates an expression
Input:
String expression
Output:
Any
Usage:
$EXPR("Hello inner world.").
$IS_AUTHORIZED
Check entity for authorization.
Input:
- Entity or Entity ID.
- Action (Read / Update / Create / Delete / Execute).
- Optional User ID. If empty, current user is used.
Output:
- True or False.
Usage:
$IS_AUTHORIZED(@item, "Read")
$IS_AUTHORIZED(@item, "Read", @USER_ID)
$IS_AUTHORIZED(@item, "Read", "F973B5C0-21B3-D4AB-870D-A42201230315")
Example:
We have a filter box (p0) containing associations of the definition Person which we are showing in a result matrix by using p0.all.
We add the below expression as a calculated column which will check if the current user is able to delete each of the associations in the p0:
$KNOWLEDGE_SET
Executes a Knowledge Set. Returns the execution result as a DataSet, suitable for further processing
Usage:
$KNOWLEDGE_SET(@KsID).
$KNOWLEDGE_SET("7f69e05c-5adc-4bce-a88b-0640c84792e5").
Example:
We have a Knowledge Set containing associations from the definition Person with the attribute Columns below:
We want to view this data structure in Application Builder as well. So we add our below expression and input the ID of the Knowledge Set to a Result Matrix in Application Builder:
$KNOWLEDGE_SET(aaa52881-f7af-78e9-1cec-b00400807535)
This will result in below view:
$Null
Returns null.
Usage:
$NULL().
$SERIAL_NO
Generates the next serial number for the given pool.Returns a number of type long
Usage:
$SERIAL_NO("GENERAL_POOL").
$STRINGFORMAT("EMP-%02d", $SERIAL_NO({POOL_NAME}))
Example:
We want to create create an expression that generates serial number for our Serial Pool named Test_Pool. This should then be used in an automation for an attribute called Serial Number within a definition named Person.
We first create the Serial Number Pool in System Management;
We then call the Serial Number Pool we just created in the automation panel within the attribute:
When we create a new association for the definition we can see the Serial Number attribute. Note that it will not generate until we save the association.
Now we have saved the new association and we can see the generated Serial Number:
$TO_COORDINATE
Creates a valid Coordinate for use in maps.
Usage:
$TO_COORDINATE(@MyLatitude, @MyLongitude).
$TO_COORDINATE(@MyStringCoordinate).
$VELOCITY_IFRAME
Returns an IFRAME HTML tag for a Velocity page.
Usage:
$VELOCITY_IFRAME("de305d54-75b4-431b-adb2-eb6b9e546014") $VELOCITY_IFRAME("HelloWorld.html")
$VELOCITY_IFRAME("de305d54-75b4-431b-adb2-eb6b9e546014","RUNTIME_ID=" + @RUNTIME_ID + "&CLICK="+@CLICK)
$VELOCITY_URL
Returns an URL for a Velocity page.
Usage:
$VELOCITY_URL("de305d54-75b4-431b-adb2-eb6b9e546014") $VELOCITY_URL("HelloWorld.html")
$VELOCITY_URL("de305d54-75b4-431b-adb2-eb6b9e546014","RUNTIME_ID=" + @RUNTIME_ID + "&CLICK="+@CLICK)
Aggregation functions
<br>
What is an Aggregate function?
These functions operates on a set of values and returns a single value as an output.
Note:
Ignores null values.
Performs an aggregation on a collection of items. Optionally grouped.
<br>
$AGGREGATE
Input:
Items - a collection of items supported by $GET() (i.e GlobalID, DataSetRow, HashMap, SelectorItem etc)
Aggregation Type - case insensitive. (Sum, Count, Average, Median, Min, Max, StdDeviation, Variance, Percentage)
Aggregation Column(s).
Optional - Group Column(s).
Output:
Always returns a DataSet.
Aggregation columns will be suffixed with the type of aggregation (e.g "Income (Sum)").
If no Group column(s) has been supplied a default "Total" column will automatically be generated and aggregation result(s) will start at column 1.
Usage:
$AGGREGATE({Dataset}, "Sum", "Amount")
$AGGREGATE({Dataset}, "Sum", "Amount", "Category")
$AGGREGATE({Dataset}, "Average", "Income", "Gender", "Age")
$AGGREGATE({p0}, "Average", $PACK("Income","Tax"), "Gender", "Age")
$AGGREGATE({p0}, "Median", $PACK("Income","Tax"), $PACK("Gender", "Age"))
Example:
In this example we have a filter box (p0) containing associations of the definition Person with an Employment and Age Attribute. We want to see the average age per Employment in a result matrix.
What we can do to achieve this is to use the aggregate function in an expression where we specify our Aggregation type as "AVG" and then add our Aggregation and group column (Age, Employment) :
$AGGREGATE({p0}, "Average", "Age", "Employment")
<br>
$AVG
Calculates the average of the given arguments.
Input:
List of numbers
Output:
Double
Usage:
$AVG(List of Numbers)
$AVG(List of Dates)
$AVG(List of Entities, attribute name or id)
$AVG(List of Global Identifiers, attribute name or id)
Example:
We have a filter box p0 containing associations of the definition Person with an Age attribute. We want to see the average age of all persons in p0. We therefore use the below expression in a calculation box, which tells Inorigo to calculate the average of the all the age attribute values in p0:
$AVG({p0.all}, "Age")
<br>
$MAX
Calculates the greater double value of two numbers.
Input:
Double, Double
Output:
Double
Usage:
$MAX(@myFirsNumber,@mySecondNumber)
$MAX(List of Numbers)
$MAX(List of Dates)
$MAX(List of Entities, attribute name or id)
$MAX(List of Global Identifiers, attribute name or id)
Example 1:
We can use $MAX to return the largest number/date in a list. We have associations of the definition Person listed in the filter box p0 that has the attribute StartDate which consist of a date. Let's say we want to see the latest date in for all these persons in p0, we can then use the below expression in calculation box:
<br>
<br>
Example 2:
We have associations of the definition Person listed in p0 which have an attribute called Scope. What we want to do is to check if the selected persons in p0 together have a scope value larger than 200. If not then return 200, and if yes then return the sum of the selected scope values. In the first image you can see that we have selected Sara Bloom, which have Scope of 90. But since it's not larger than the 200 we specified it will not change in the top calculation box
<br>
$MAX($SUM({p0},"Scope"), 200)
Returns 200 or the selected sum of Scope in p0, whichever being the largest.
<br>
But now we select more people which brings our total scope values to that of 205. The top calculation box now changes to 205 as the sum is over 200.
<br>
$MIN
Calculates the smaller double value of two numbers.
Input:
Double, Double
Output:
Double
Usage:
$MIN(@myFirsNumber,@mySecondNumber)
$MIN(List of Numbers)
$MIN(List of Dates)
$MIN(List of Entities, attribute name or id)
$MIN(List of Global Identifiers, attribute name or id)
Example 1
We can use $MIN to return the smallest number/date in a list. Here we have persons associations listed in p0 (Person) which has the attribute StartDate which consist of a date. Let's say we want to see the earliest date in for all these persons in p0, we can then use the below expression in calculation box:
$MIN($GET({p0}, "StartDate"))
<br>
Example 2
$MIN($SUM({p0},"Age"), 50)
Returns 50 or the sum of p0, whichever being the smallest.
In this example we have a filter box containing associations of the definition Person with the attribute age. We want to see if the sum of the selected ages in the filter box p0 (Person) is below 50, if yes return return the sum of selected ages, if no then return 50.
Here we have only selected one person that have an age of 35, and since it is smaller than 50, the top Calculation box returns the sum of ages selected (35).
<br>
<br>
But here we have selected more people in the filter box which brings our total sum of the ages combined to 98. And since this age sum is larger than 50 the expression will return 50 in the top result Calculation box.
<br>
$PERCENT
Creates a dataset with added percentage column(s).
Input:
Items. A collection of DataSet rows, like a normal dataset or the result of an Aggregation
Value Column(s).
Optional - Total Grouping Column(s).
Output:
Always returns a DataSet.
Aggregation columns will be suffixed with % (e.g "Income %").
If no Grouping column(s) has been supplied, the total is simply the sum of all values in the Value column.
Usage:
$PERCENT({Dataset}, "Amount", "Category")
$PERCENT({Dataset}, "Income", "Gender", "Age")
$PERCENT({Dataset}, $PACK("Income","Tax"), "Gender", "Age")
$PERCENT({Dataset}, $PACK("Income","Tax"), $PACK("Gender", "Age"))
Example:
In the below example we have a dataset (DS) containing associations of the definition Person with the attributes Employment, and Income.
<br>
<br>
Using the below expression in a Result Matrix will output the percentage of the total Income per Employment for each row in the dataset DS. Where our dataset is the items input, Income is the value column and Employment is the total grouping column
<br>
$PERCENT({DS}, "Income", "Employment")
<br>
$SUM
Returns summary of values.
This function is used for summarizing lists, plus a reference to the object attribute value to be summed.
Input:
Collection of numbers or Collection<GID/DataObject>, String attribute
Output:**
Double
<br>
Usage:
$SUM(List of Numbers)
$SUM(List of Dates)
$SUM(List of Entities, attribute name or id)
$SUM(List of Global Identifiers, attribute name or id)
<br>
Example:
In this example we have a filter box p0 containing associations of the definition Person with the attribute age. We want to see the sum of all the selected age attributes values in a calculation box, so we add the below expression. Here p0 is the collection of items input and "Age" is our string attribute:
$SUM({p0}, "Age")
© 2025 Inorigo AB. All rights reserved.