Creates a CustomCalculation for a Group. Each CustomCalculation defines a column in the output data which is filled with values calculated using the given formula for each element that is returned by the Group's query.
CustomCalculations
CustomCalculation is a type of Group property which contains a formula. CustomCalculation defines a column in the output data that gets filled with the formula evaluation result. The formula is evaluated for each row of the Group's query result during each extraction.
The formula supports using other columns (GroupProperty, CalculatedProperty or CustomCalculation entities) as variables. Recursive formulas are not supported, i.e., formula containing a variable X
is not supported inside a CustomCalculation with a propertyName
equal to X
.
Supported data types:
- Number - describes a real number. When converted to a boolean value in logical operators
0
becomesfalse
and all other values becometrue
- Boolean - describes a logical value which is either true or false. When converted to a number in certain operators
true
becomes1
andfalse
becomes0
- String - describes text. When converted to a boolean value in logical operators an empty string becomes
false
and all other strings becometrue
All of the supported data types can have no value which means that the value is null
. Some operations support null
values but those which do not will return null
as the result.
Supported operators:
-
!
**
*
/
%
+
-
<
<=
>
>=
==
!=
&&
||
Parenthesis (
and )
can be used to change the precedence of operations. Variables, constants, and functions have a precedence of 1 and left associativity.
Supported constants:
E
- Euler's constant and the base of natural logarithms (approx. 2.718)LN2
- natural logarithm of 2 (approx. 0.693)LN10
- natural logarithm of 10 (approx. 2.303)LOG2E
- base-2 logarithm ofE
(approx. 1.443)PI
- ratio of a circle's circumference to its diameter (approx. 3.14159)SQRT1_2
- square root of ½ (approx. 0.707)SQRT2
- square root of 2 (approx. 1.414)
Supported numeric constant formats:
- Decimal, e.g.,
123
or1.123
- Binary (base 2), e.g.,
0b1010
- Octal (base 8), e.g.,
0o1234567
- Hexadecimal (base 16), e.g.,
0x123af
- Scientific notation, e.g.,
1.123e+3
Supported string literal formats:
- Single quotation marks, e.g.,
'Column'
- Double quotation marks, e.g.,
"Column"
- Backticks, e.g.,
`Column`
Supported boolean formats:
- True, e.g.,
true
- False, e.g.,
false
Supported null format:
- Null, e.g.,
null
An escape character \
can be used to escape special characters in string literals. Supported escape sequences:
\'
- single quotation mark\"
- double quotation mark\`
- backtick\\
- backslash\n
- newline character\t
- tab character
If an unsupported escape sequence is found, then the escape character is dropped, e.g., \d
becomes d
.
Supported numerical functions:
abs(x)
- returns the absolute value ofx
acos(x)
- returns the arccosine ofx
acosh(x)
- returns the hyperbolic arccosine ofx
asin(x)
- returns the arcsine ofx
asinh(x)
- returns the hyperbolic arcsine ofx
atan(x)
- returns the arctangent ofx
atanh(x)
- returns the hyperbolic arctangent ofx
atan2(y, x)
- returns the arctangent of the quotient ofy
divided byx
cbrt(x)
- returns the cube root ofx
ceil(x)
- returns the smallest integer greater than or equal tox
clz32(x)
- returns the number of leading zero bits of the 32-bit integerx
cos(x)
- returns the cosine ofx
cosh(x)
- returns the hyperbolic cosine ofx
exp(x)
- returnsE ** x
orpow(E, x)
, wherex
is the argument, andE
is Euler's constant (2.718…, the base of the natural logarithm)expm1(x)
- returns subtracting 1 fromexp(x)
floor(x)
- returns the largest integer less than or equal tox
fround(x)
- returns the nearest single precision float representation ofx
hypot(x, y[, z[, …]])
- returns the square root of the sum of squares of its argumentsimul(x, y)
- returns the result of the 32-bit integer multiplication ofx
andy
log(x)
- returns the natural logarithm ofx
log1p(x)
- returns the natural logarithm of1 + x
log10(x)
- returns the base-10 logarithm ofx
log2(x)
- returns the base-2 logarithm ofx
max(x, y[, z[, …]])
- returns the largest of 2 or more numbersmin(x, y[, z[, …]])
- returns the smallest of 2 or more numberspow(x, y)
- returns basex
to the exponent powery
(i.e.,x**y
)random()
- returns a pseudo-random number between 0 and 1. The value only changes between different output tables. All rows within a single output table get the same valueround(x)
- returns the value of the numberx
rounded to the nearest integersign(x)
- returns the sign of thex
, indicating whetherx
is positive (1
), negative (-1
), or zero (0
)sin(x)
- returns the sine ofx
sinh(x)
- returns the hyperbolic sine ofx
sqrt(x)
- returns the positive square root ofx
tan(x)
- returns the tangent ofx
tanh(x)
- returns the hyperbolic tangent ofx
trunc(x)
- returns the integer portion ofx
, removing any fractional digitstonumber(var)
- returns thevar
value converted to a number
Supported string functions:
charat(str, index)
- returns exactly one character at the specified index. Accepts negative integers, which count back from the last string characterconcat(str , ...strN)
- combines the text of two (or more) strings and returns a new stringpadend(str, targetLength [, padString])
- pads the given string from the end with a given string and returns a new string of the lengthtargetLength
. Maximum value oftargetLength
is100
. The resulting string will be truncated if it is too long to stay withintargetLength
. The default value forpadString
is " " (white space)padstart(str, targetLength [, padString])
- pads the given string from the start with a given string and returns a new string of the lengthtargetLength
. Maximum value oftargetLength
is100
. The resulting string will be truncated if it is too long to stay withintargetLength
. The default value forpadString
is " " (white space)substring(str, beginIndex [, endIndex])
- returns a new string containing characters ofstr
from (or between) the specified index (or indices)indexof(str, searchValue [, start])
- returns the index of the first occurance instr
at which a given stringsearchValue
can be found in the array, or -1 if it is not present.tolowercase(str)
- returns thestr
value converted to lowercasetouppercase(str)
- returns thestr
value converted to uppercasetrim(str)
- trims whitespace from the beginning and end ofstr
trimstart(str)
- trims whitespace from beginning ofstr
trimend(str)
- trims whitespace from end ofstr
tostring(var)
- returns thevar
value converted to a string
Supported boolean functions:
isin(var, var1[, var2[, ...]])
- returnstrue
ifvar
is equal to one ofvar1, ...varN
else it returnsfalse
.var, ...varN
must be of same typetoboolean(var)
- returns thevar
value converted to a boolean
Supported conditional functions:
if(cond, expr_true, expr_false)
- returnsexpr_true
ifcond
istrue
else it returnsexpr_false
.expr_true
andexpr_false
must be of the same type.expr_true
andexpr_false
can benull
ifnull(var, expr)
- returnsexpr
ifvar
isnull
else it returnsvar
.var
andexpr
must be of the same type.var
can benull
ifnotnull(var, expr)
- returnsexpr
ifvar
is notnull
else it returnsvar
.var
andexpr
must be of the same type.var
can benull
ifempty(str, expr)
- returnsexpr
ifstr
is empty else it returnsstr
.str
andexpr
must be stringsifnotempty(str, expr)
- returnsexpr
ifstr
is not empty else it returnsstr
.str
andexpr
must be stringsifnullorempty(str, expr)
- returnsexpr
ifstr
is null or empty else it returnsstr
.str
andexpr
must be strings.str
can benull
ifnotnullorempty(str, expr)
- returnsexpr
ifstr
is not null and not empty else it returnsstr
.str
andexpr
must be strings.str
can benull
ifnullorwhitespace(str, expr)
- returnsexpr
ifstr
is null or empty or only consists of whitespace else it returnsstr
.str
andexpr
must be strings.str
can benull
ifnotnullorwhitespace(str, expr)
- returnsexpr
ifstr
is not null and not empty and not only consists of whitespace else it returnsstr
.str
andexpr
must be strings.str
can benull
Supported unit functions:
getpersistenceunit(var)
- returns persistence unit of the provided argument as aString
. Provided argument must be a GroupProperty that is mapped from an ECProperty and has data type set toDouble
. Example value:Units.M
. More information about units can be found heregetpresentationunits(var)
- returns serialized json array of presentation units of the provided argument as aString
. Provided argument must be a GroupProperty that is mapped from an ECProperty and has data type set toDouble
. Example value:[\"Units.M\",\"Units.FT\"]
. More information about units can be found here
Examples of supported formulas:
min(A * B, B * C, A * C)
- ifA
,B
, andC
are 3 different lengths of box edges, then this formula will result in the smallest side surface area of that boxmin * max
- formula does not have parenthesis after function names, so themin
andmax
operands are treated as variables (other columns), not as functions. If the Group has columnsmin
andmax
, and their values are2
and5
, then the result of this formula is10
for that row2 ** 3
- 2 raised to the power of 3. Result will be 8. This can also be written aspow(2, 3)
min(cos(X), sin(X))
- function nesting is supportedA * (B + C)
-A
multiplied by the sum ofB
andC
A * B + C
- same as(A * B) + C
padend(concat(A, '\\', touppercase(substring(B, 4))), C, D)
- the result ofconcat
, which concatenates variableA
, string literal\
anduppercase
substring
of variableB
from index4
, is padded in the end with the target length ofC
with a pad string of variableD
charat(trim(A), B)
- gets the character of a trimmed string variableA
that is at indexB
if(A > B, A, B)
- ifA
is greater thanB
then the result isA
else it isB
ifnullorempty(A, 'B = ') + B
- if variableA
is null or empty then the result ofifnullorempty
function is the string literalB =
else it is variableA
. Then the final formula result is the addition of the result ofifnullorempty
function and variableB
if(A != null && B != null, A + B, 0)
- ifA
is not null andB
is not null then the result is the addition ofA
andB
else it is0
Authentication
Requires Authorization
header with valid Bearer token for scope itwin-platform
.
For more documentation on authorization and how to get access token visit OAUTH2 Authorization page.
Authorization
User must have imodels_write
permission(s) assigned at the Project level. iModel specific permissions may also be applied at the iModel level if iModel level permissions are enabled.
Alternatively the user should be an Organization Administrator for the Organization that owns a given Project or iModel.
An Organization Administrator must have at least one of the following roles assigned in User Management: Account Administrator, Co-Administrator, or CONNECT Services Administrator. For more information about User Management please visit our Bentley Communities Licensing, Cloud, and Web Services wiki page.
Rate limits
All iTwin Platform API operations have a rate limit. For more documentation on that visit Rate limits and quotas page.
"Try it out" Limitations
When you run an Extraction with the "Try it out" function on a Mapping that was created or modified by using the "Try it out" function, you are limited to 100 extracted rows for each group. Mapping modification is any POST/DELETE/PATCH/PUT request to any endpoint with the tag "Mappings" or if the URL contains {mappingId}.
Was this page helpful?