workbook.createMeasure(options)

Note:

The content in this help topic applies to SuiteScript 2.x.

Method Description

Creates a measure, which includes an aggregation, a label, and one or more expressions.

Returns

workbook.Measure

Supported Script Types

Server scripts

For more information, see SuiteScript 2.x Script Types.

Governance

None

Module

N/workbook Module

Sibling Module Members

N/workbook Module Members

Since

2020.2

Parameters

Note:

The options parameter is a JavaScript object.

Parameter

Type

Required / Optional

Description

options.aggregation

string

optional

The aggregation of the measure.

option.expression

workbook.Expression

required if options.expressions is not specified

A single expression for the measure (if this is a single expression measure).

options.expressions

workbook.Expression[]

required if options.expression is not specified

A set of expressions for the measure (if this is a multi expression measure).

options.label

string

optional

The label of the measure.

Errors

Error Code

Thrown If

AT_LEAST_ONE_EXPRESSION_IS_NEEDED

The options.expressions parameter is empty.

MUTUALLY_EXCLUSIVE_ARGUMENTS

Both the options.expression and options.expressions parameters are specified. Only specify one of these parameters.

Syntax

Important:

The following code sample shows the syntax for this member. It is not a functional example. For a complete script example, see N/workbook Module Script Samples.

            // Add additional code
...
// Create a basic single expression Measure
var myMeasure = workbook.createMeasure({
    expression: myExpression
});

// Create a basic multi-expression Measure
var myMeasure = workbook.createMeasure({
    expressions: [myExpression]
});

// Create a comprehensive single expression Measure
var myMeasure = workbook.createMeasure({
    label: 'My Measure',
    aggregation: workbook.Aggregation.MEDIAN,
    expression: myExpression
});

// Create a comprehensive multi-expression Measure
var myMeasure = workbook.createMeasure({
    label: 'My Measure',
    aggregation: workbook.Aggregation.SUM,
    expressions: [myExpression]
});
...
// Add additional code 

          

Related Topics

N/workbook Module
SuiteScript 2.x Modules
SuiteScript 2.x

General Notices