Expressions

Note:

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

Expressions represent queries or arithmetic operations that use data in the underlying dataset or calculate custom values. You can create an expression that represents a column in the underlying dataset, or you can create a custom expression using a function that you specify (such as comparison and consolidation operations).

To create an expression based on a column in the underlying dataset, use Dataset.getExpressionFromColumn(options). This method creates a workbook.Expression object. When you use this method, you must provide either the alias parameter (to specify a dataset column using its alias) or the columnId parameter (to specify a dataset column using its ID), but you cannot provide both parameters at the same time.

          var myColumnExpression = myDataset.getExpressionFromColumn({
    alias: 'MyColumn'
}); 

        

After you obtain a column expression, you can use it in several other methods:

To create a custom expression, use workbook.createExpression(options). This method creates a workbook.Expression object. When you use this method, only the functionId parameter is required, and it represents the operation that is performed to calculate the expression. Use values from the workbook.ExpressionType enum for this parameter. The parameters parameter is optional and represents the parameters or operands for the function. Not all functions require parameters or operands.

          var myCustomExpression = workbook.createExpression({
    functionId: workbook.ExpressionType.CONSOLIDATE,
    parameters: {
        expression: myDataset.getExpressionFromColumn({
            alias: 'MyColumn'
        })
    }
}); 

        

For descriptions of each function you can use in an expression, see workbook.ExpressionType.

Related Topics

Data Dimensions
Data Measures and Calculated Measures
Pivot Axes
Selectors
Styles
Pivots

General Notices