Add and Update Calculated Measures

Add and Update Calculated Measures

This documentation is for Kyvos 2026.6.x. To view documentation for other Kyvos versions, click here.

This documentation is for Kyvos 2026.6.x. To view documentation for other Kyvos versions, click here.

Overview

This API adds or updates a calculated measure in the Semantic Model. It only works for calculated measures. If the measure is not calculated, the update will be ignored.

Method: POST

Request URL: {kyvos-url}/rest/v2/semantic-models/{name-or-id}/calculated-measures/save


Authorization

API Key: sessionid

This method authenticates requests using a session ID which acts like an API key.


BasicAuth: HTTP Authorization Scheme

This method authenticates requests using a username and password sent in the HTTP Authorization header.


Headers

Header Name

Type

Description

Possible Values

Header Name

Type

Description

Possible Values

Content-Type (Required)

String

Specifies the media type of the request body.

application/x-www-form-urlencoded

sessionid

String

The session ID is the token received from the login API.

Note: Session ID is required for token-based authentication.

–


Path Parameters

Parameter Name

Type

Description

Possible Values

Parameter Name

Type

Description

Possible Values

name-or-id (Required)

String

Name or ID of the Semantic Model in which calculated measures need to be added or updated.

Note: If the Semantic Model name is provided, then either folderName or folderId must also be provided.

–


Query Parameters

Parameter Name

Type

Description

Possible Values

Parameter Name

Type

Description

Possible Values

by

String

Specifies whether the name-or-id parameter should be interpreted as a Semantic Model name or Semantic Model ID.

If by=name, provide the Semantic Model name in the name-or-id parameter.

If by=id, provide the Semantic Model ID in the name-or-id parameter.

The default value is name.

–

folderName

String

Name of the folder containing the Semantic Model. If the Semantic Model is present in the root directory, specify [Root].

Note: If neither folderName nor folderId is provided, the Semantic Model will be treated as a root-level entity by default.

–

folderId

String

ID of the folder containing the Semantic Model.

–


Request Body

Parameter Name

Type

Description

Possible Values

Parameter Name

Type

Description

Possible Values

validate

Boolean

Indicates whether the calculated measure expressions should be validated before saving.

true, false

measuresJson (Required)

String

A JSON string where each key represents a measure name and its value contains a JSON object defining the measure's properties.

Note: An example JSON is provided under the Resources section below.

–


Responses

200 Success

{ "code": 0, "message": "Successfully updated semantic model object: account" }

Status Code

Description

Status Code

Description

401

Authorization information is missing or invalid.

404

No matching record found.

412

Precondition failed. Parameter missing.

500

Internal Server Error.


Resources

Below is an example of JSON structure which can be used as a reference for the measuresJson parameter in the request body.

{ "measureName1":{ "expression":"[Measures].[Amount]*[Measure].[ID]", "description":"description1", "groupName":"MeasureGroup", "groupDescription":"groupDescription1", "solveOrder":"1", "formatType":"Number", "format":"#,##0.00", "isVisible":false, "nonEmptyBehaviour":"BY_MEASURE", "nonEmptyMeasures":"ID" } }

JSON Fields Description

Field

Type

Description

Possible Values

Example

(root)

JSON Object

Root JSON object where each key is the calculated measure name and value is the measure configuration

Object with measure name keys

{"Total Revenue": {...}}

{measureName}

JSON Object

Configuration for a calculated measure. The key itself is the measure name

-

{"expression": "...", ...}

measureId

String

Unique identifier of an existing calculated measure. Required for UPDATE operations. If provided, the system will look up the measure by ID first, then by name

Measure GUID

"measure_17764122062715"

{measureName}.expression

String

MDX expression that defines the calculated measure. This is the formula used to compute the measure value. Required field

Valid MDX expression

"[Measures].[Sales Amount] * [Measures].[Quantity]"

semanticModelId

String

Unique identifier of the semantic model (cube) this calculated measure is based on. Either semanticModelId or semanticModelName is required

Semantic Model GUID

"cube_17764122062715"

semanticModelName

String

Name of the semantic model (cube) this calculated measure is based on. Either semanticModelId or semanticModelName is required

Semantic Model name

"Sales Cube"

semanticModelFolderName

String

Folder name where the semantic model resides. Used in combination with semanticModelName to uniquely identify the semantic model

Folder name

"Sales"

groupName

String

Name of the measure group where this calculated measure will be placed. Required for ADD operations (new measures)

Measure group name

"Revenue Measures"

{measureName}.format

String

Display format pattern for the measure values. Controls how numbers are displayed in reports

Format pattern

"#,##0.00"

formatType

String

Type of format to apply. 0=custom format, other values for predefined formats

"0","1"

"0"

solveOrder

Integer

Solve order for the calculated measure. Determines the order in which calculated measures are evaluated when multiple measures depend on each other. Higher values are evaluated later

Integer value

0

description

String

Description of the calculated measure explaining its purpose and usage

Free-form text

"Total revenue calculated as sales amount times quantity"

displayFolder

String

Display folder path for organizing the measure in the UI. Uses backslash as separator for nested folders

Folder path

"Revenue\\Calculated"

.isVisible

Boolean

Whether the measure is visible to end users in reports and visualizations

TRUE,FALSE

TRUE

.nonEmptyBehavior

String

Defines how the measure handles empty cells. BY_MEASURE=use measure's own logic, BY_MEASURES=use specified measures

"BY_MEASURE","BY_MEASURES"

"BY_MEASURE"

nonEmptyMeasures

String

Comma-separated list of measure IDs to use for non-empty behavior when nonEmptyBehavior is BY_MEASURES

Comma-separated measure IDs

"measure_1,measure_2"

Additional Information for JSON Example

Format Type

The formatType field can be provided either as a string or as a numerical value based on the following mapping:

  • 2 – Number

  • 3 – Currency

  • 4 – Date

  • 5 – Time

  • 6 – Percentage

  • 7 – Scientific

  • 9 – Custom

  • 10 – Duration

Non-Empty Behaviour

The nonEmptyBehaviour field determines how the system evaluates whether a calculated measure is empty. Supported values include:

  • BY_EXPRESSION
    The expression itself is evaluated to determine if the calculated measure is empty.

  • BY_MEASURE
    The calculated measure is treated as empty if all the specified measures are empty.

  • BY_MEASURE_THEN_EXPRESSION
    The calculated measure is treated as empty if all specified measures are empty, or if the evaluated expression is empty.

 

Copyright Kyvos, Inc. 2026. All rights reserved.