Data Measures and Calculated Measures

Note:

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

Data measures let you perform simple aggregations on the data in a column in the underlying dataset. For example, you can define a data measure that counts the number of distinct values that appear in a column. Calculated measures let you perform simple arithmetic operations based on the values in a column or using another measure or expression. For example, you can define a calculated measure that calculates the difference between the values of two other measures.

For more information about measures in SuiteAnalytics Workbook, see Calculated Measures.

To create a data measure, use workbook.createDataMeasure(options). This method creates a workbook.DataMeasure object. When you use this method, you must provide the following parameters:

Optionally, you can provide a label parameter for the data measure.

          var myDataMeasure = workbook.createDataMeasure({
    aggregation: workbook.Aggregation.SUM,
    expressions: [dataset.getExpressionFromColumn({
        alias: 'MyColumn'
    })],
    label: 'My Sum'
}); 

        

To create a calculated measure, use workbook.createCalculatedMeasure(options). This method creates a workbook.CalculatedMeasure object. When you use this method, only the options.expression parameter is required, and it represents the expression for the calculated measure. Use workbook.createExpression(options) to create this expression, and use the functions from the workbook.ExpressionType enum.

Important:

For the top-level expression that you use in a calculated measure, only the PLUS, MINUS, DIVIDE, and MULTIPLY operands are valid. However, you can use other operands in expressions for each parameter in the top-level calculated measure.

Optionally, you can provide a label parameter for the calculated measure.

          var myCalculatedMeasure = workbook.createCalculatedMeasure({
    expression: workbook.createExpression({
        functionId: workbook.ExpressionType.MINUS,
        parameters: {
            operand1: myFirstOperandExpression,
            operand2: mySecondOperandExpression
        }
    }),
    label: 'My Calculated Measure'
}); 

        

Related Topics

Data Dimensions
Expressions
Pivot Axes
Selectors
Styles
Pivots

General Notices