Updates a CustomCalculation for a Group.
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
0becomesfalseand all other values becometrue - Boolean - describes a logical value which is either true or false. When converted to a number in certain operators
truebecomes1andfalsebecomes0 - String - describes text. When converted to a boolean value in logical operators an empty string becomes
falseand 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.,
123or1.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 ofxacos(x)- returns the arccosine ofxacosh(x)- returns the hyperbolic arccosine ofxasin(x)- returns the arcsine ofxasinh(x)- returns the hyperbolic arcsine ofxatan(x)- returns the arctangent ofxatanh(x)- returns the hyperbolic arctangent ofxatan2(y, x)- returns the arctangent of the quotient ofydivided byxcbrt(x)- returns the cube root ofxceil(x)- returns the smallest integer greater than or equal toxclz32(x)- returns the number of leading zero bits of the 32-bit integerxcos(x)- returns the cosine ofxcosh(x)- returns the hyperbolic cosine ofxexp(x)- returnsE ** xorpow(E, x), wherexis the argument, andEis 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 toxfround(x)- returns the nearest single precision float representation ofxhypot(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 ofxandylog(x)- returns the natural logarithm ofxlog1p(x)- returns the natural logarithm of1 + xlog10(x)- returns the base-10 logarithm ofxlog2(x)- returns the base-2 logarithm ofxmax(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 basexto 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 numberxrounded to the nearest integersign(x)- returns the sign of thex, indicating whetherxis positive (1), negative (-1), or zero (0)sin(x)- returns the sine ofxsinh(x)- returns the hyperbolic sine ofxsqrt(x)- returns the positive square root ofxtan(x)- returns the tangent ofxtanh(x)- returns the hyperbolic tangent ofxtrunc(x)- returns the integer portion ofx, removing any fractional digitstonumber(var)- returns thevarvalue 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 oftargetLengthis100. The resulting string will be truncated if it is too long to stay withintargetLength. The default value forpadStringis " " (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 oftargetLengthis100. The resulting string will be truncated if it is too long to stay withintargetLength. The default value forpadStringis " " (white space)substring(str, beginIndex [, endIndex])- returns a new string containing characters ofstrfrom (or between) the specified index (or indices)indexof(str, searchValue [, start])- returns the index of the first occurance instrat which a given stringsearchValuecan be found in the array, or -1 if it is not present.tolowercase(str)- returns thestrvalue converted to lowercasetouppercase(str)- returns thestrvalue converted to uppercasetrim(str)- trims whitespace from the beginning and end ofstrtrimstart(str)- trims whitespace from beginning ofstrtrimend(str)- trims whitespace from end ofstrtostring(var)- returns thevarvalue converted to a string
Supported boolean functions:
isin(var, var1[, var2[, ...]])- returnstrueifvaris equal to one ofvar1, ...varNelse it returnsfalse.var, ...varNmust be of same typetoboolean(var)- returns thevarvalue converted to a boolean
Supported conditional functions:
if(cond, expr_true, expr_false)- returnsexpr_trueifcondistrueelse it returnsexpr_false.expr_trueandexpr_falsemust be of the same type.expr_trueandexpr_falsecan benullifnull(var, expr)- returnsexprifvarisnullelse it returnsvar.varandexprmust be of the same type.varcan benullifnotnull(var, expr)- returnsexprifvaris notnullelse it returnsvar.varandexprmust be of the same type.varcan benullifempty(str, expr)- returnsexprifstris empty else it returnsstr.strandexprmust be stringsifnotempty(str, expr)- returnsexprifstris not empty else it returnsstr.strandexprmust be stringsifnullorempty(str, expr)- returnsexprifstris null or empty else it returnsstr.strandexprmust be strings.strcan benullifnotnullorempty(str, expr)- returnsexprifstris not null and not empty else it returnsstr.strandexprmust be strings.strcan benullifnullorwhitespace(str, expr)- returnsexprifstris null or empty or only consists of whitespace else it returnsstr.strandexprmust be strings.strcan benullifnotnullorwhitespace(str, expr)- returnsexprifstris not null and not empty and not only consists of whitespace else it returnsstr.strandexprmust be strings.strcan 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, andCare 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 theminandmaxoperands are treated as variables (other columns), not as functions. If the Group has columnsminandmax, and their values are2and5, then the result of this formula is10for 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)-Amultiplied by the sum ofBandCA * B + C- same as(A * B) + Cpadend(concat(A, '\\', touppercase(substring(B, 4))), C, D)- the result ofconcat, which concatenates variableA, string literal\anduppercasesubstringof variableBfrom index4, is padded in the end with the target length ofCwith a pad string of variableDcharat(trim(A), B)- gets the character of a trimmed string variableAthat is at indexBif(A > B, A, B)- ifAis greater thanBthen the result isAelse it isBifnullorempty(A, 'B = ') + B- if variableAis null or empty then the result ofifnulloremptyfunction is the string literalB =else it is variableA. Then the final formula result is the addition of the result ofifnulloremptyfunction and variableBif(A != null && B != null, A + B, 0)- ifAis not null andBis not null then the result is the addition ofAandBelse 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}.
Request parameters
The iModel Id.
The Mapping Id.
The Group Id.
Id of the CustomCalculation to be updated.
Request headers
OAuth access token with itwin-platform scope
Setting to application/vnd.bentley.itwin-platform.v1+json is recommended.
Request body
CustomCalculation (update)
Name of the Property (OData v4 SimpleIdentifier).
A mathematical formula which will be evaluated for each element returned by the Group's query.
The quantity type of the CustomCalculation. One of 'Area', 'Distance', 'Force', 'Mass', 'Monetary', 'Time', 'Volume, or 'Undefined'.
Example
{ "propertyName": "UpdatedVolume", "formula": "Length * Width * Height", "quantityType": "Volume" }
Response 200 OK
Updated a CustomCalculation successfully.
{ "customCalculation": { "id": "1ba1f4dd-efc1-4bd1-86f0-a69a4f0d4743", "propertyName": "CalculatedPrice", "formula": "CalculatedVolume * 3.123", "dataType": "Number", "quantityType": "Monetary", "_links": { "imodel": { "href": "https://api.bentley.com/imodels/70a3d6d3-5385-4bc3-87c4-b6bf106e1c0a" }, "mapping": { "href": "https://api.bentley.com/insights/reporting/datasources/imodels/70a3d6d3-5385-4bc3-87c4-b6bf106e1c0a/mappings/f1fe5959-35ab-467e-83b8-a679b722d80f" }, "group": { "href": "https://api.bentley.com/insights/reporting/datasources/imodels/70a3d6d3-5385-4bc3-87c4-b6bf106e1c0a/mappings/f1fe5959-35ab-467e-83b8-a679b722d80f/groups/1d9ae44a-2204-4bf6-8397-5c590e04ba3e" } } } }
Response 401 Unauthorized
This response indicates that request lacks valid authentication credentials. Access token might not been provided, issued by the wrong issuer, does not have required scopes or request headers were malformed.
{ "error": { "code": "HeaderNotFound", "message": "Header Authorization was not found in the request. Access denied." } }
Response 404 Not Found
Specified CustomCalculation was not found.
{ "error": { "code": "CustomCalculationNotFound", "message": "Requested CustomCalculation is not available.", "target": "customCalculationId" } }
Response 409 Conflict
CustomCalculation with the same name already exists within the Group.
{ "error": { "code": "CustomCalculationExists", "message": "CustomCalculation with this 'propertyName' already exists." } }
Response 422 Unprocessable Entity
The 422 (Unprocessable Entity) status code indicates that the request cannot be processed by the server due to a client error (e.g. malformed request syntax).
{ "error": { "code": "InvalidInsightsRequest", "message": "Error message." } }
Response 429 Too many requests
This response indicates that the user has sent too many requests in a given amount of time.
{ "error": { "code": "TooManyRequests", "message": "More requests were received than the subscription rate-limit allows." } }
Response headers
The number of requests exceeds the rate-limit for the client subscription.
CustomCalculation
Defines a CustomCalculation or 'column' for a Group. It is calculated using the given formula for each element returned by the Group's query.
The CustomCalculation Id.
Name of the Property (OData v4 SimpleIdentifier).
The data type of the GroupProperty. One of 'Boolean', 'Double', 'Number', 'String', or 'Undefined'.
A mathematical formula which will be evaluated for each element returned by the Group's query.
The quantity type of the CustomCalculation. One of 'Area', 'Distance', 'Force', 'Mass', 'Monetary', 'Time', 'Volume, or 'Undefined'.
{ "title": "CustomCalculation", "type": "object", "description": "Defines a CustomCalculation or 'column' for a Group. It is calculated using the given formula for each element returned by the Group's query.", "properties": { "id": { "type": "string", "description": "The CustomCalculation Id." }, "propertyName": { "type": "string", "description": "Name of the Property (OData v4 SimpleIdentifier)." }, "dataType": { "type": "string", "description": "The data type of the GroupProperty. One of 'Boolean', 'Double', 'Number', 'String', or 'Undefined'." }, "formula": { "type": "string", "description": "A mathematical formula which will be evaluated for each element returned by the Group's query." }, "quantityType": { "type": "string", "description": "The quantity type of the CustomCalculation. One of 'Area', 'Distance', 'Force', 'Mass', 'Monetary', 'Time', 'Volume, or 'Undefined'." }, "_links": { "type": "object", "properties": { "imodel": { "$ref": "#/components/schemas/Link", "description": "URL pointing to the related iModel." }, "mapping": { "$ref": "#/components/schemas/Link", "description": "URL pointing to the related Mapping." }, "group": { "$ref": "#/components/schemas/Link", "description": "URL pointing to the related Group." } } } }, "additionalProperties": false }
CustomCalculation Response
Container for a CustomCalculation object.
{ "title": "CustomCalculation Response", "type": "object", "description": "Container for a CustomCalculation object.", "properties": { "customCalculation": { "$ref": "#/components/schemas/CustomCalculation", "description": "CustomCalculation properties." } }, "additionalProperties": false }
CustomCalculation (update)
Properties of the CustomCalculation to be updated.
Name of the Property (OData v4 SimpleIdentifier).
A mathematical formula which will be evaluated for each element returned by the Group's query.
The quantity type of the CustomCalculation. One of 'Area', 'Distance', 'Force', 'Mass', 'Monetary', 'Time', 'Volume, or 'Undefined'.
{ "title": "CustomCalculation (update)", "type": "object", "description": "Properties of the CustomCalculation to be updated.", "properties": { "propertyName": { "type": "string", "description": "Name of the Property (OData v4 SimpleIdentifier)." }, "formula": { "type": "string", "description": "A mathematical formula which will be evaluated for each element returned by the Group's query." }, "quantityType": { "type": "string", "description": "The quantity type of the CustomCalculation. One of 'Area', 'Distance', 'Force', 'Mass', 'Monetary', 'Time', 'Volume, or 'Undefined'." } }, "additionalProperties": false }
Link
Hyperlink container.
Hyperlink to the specific entity.
{ "title": "Link", "type": "object", "description": "Hyperlink container.", "properties": { "href": { "type": "string", "description": "Hyperlink to the specific entity." } }, "additionalProperties": false }
Error
Contains error information.
One of a server-defined set of error codes.
A human-readable representation of the error.
The target of the error.
{ "type": "object", "description": "Contains error information.", "properties": { "code": { "type": "string", "description": "One of a server-defined set of error codes." }, "message": { "type": "string", "description": "A human-readable representation of the error." }, "target": { "type": "string", "description": "The target of the error.", "nullable": true } }, "required": [ "code", "message" ], "additionalProperties": true }
Error Response
Gives details for an error that occurred while handling the request. Note that clients MUST NOT assume that every failed request will produce an object of this schema, or that all of the properties in the response will be non-null, as the error may have prevented this response from being constructed.
{ "type": "object", "title": "Error Response", "description": "Gives details for an error that occurred while handling the request. Note that clients MUST NOT assume that every failed request will produce an object of this schema, or that all of the properties in the response will be non-null, as the error may have prevented this response from being constructed.", "properties": { "error": { "description": "Error information.", "$ref": "#/components/schemas/Error" } }, "required": [ "error" ], "additionalProperties": false }
Was this page helpful?