☝️Small business or a startup? See if you qualify for our special offer.
+
All documentation

addCalculatedMeasure

addCalculatedMeasure(measure: Object)

[starting from version: 2.3]

Adds a calculated value.

Note You can add calculated value only for reports based on the "json", "csv", and "api" data source types.

Learn more about calculated measures in this guide: Calculated values.

Parameters

Property/TypeDescription
measure
MeasureObject
The object that describes the calculated value. Note that a calculated value must have the formula property defined.

Example

In the example below, we add the "Average Quantity" calculated value. The formula is sum("Quantity")/count("Quantity"). The calculated value will be added to the list of available measures and selected for the slice (active: true):

let measure = {
formula: 'sum("Quantity")/count("Quantity")',
uniqueName: "Average Quantity",
caption: "Average Quantity",
grandTotalCaption: "Total Quantity",
active: true
};

pivot.addCalculatedMeasure(measure);

Live example

See also