Expressions

Expressions are used to query or perform math operations on dataset data or calculate custom values. You can create expressions based on dataset columns or use custom functions for comparisons and other operations.

You can create a column-based expression using Dataset.getExpressionFromColumn(options). This method creates a workbook.Expression object. To create a column expression, 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 can't provide both.

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

        

When you have a column expression, you can use it in various other methods.

You can create a custom expression using workbook.createExpression(options). This method creates a workbook.Expression object. To create a custom expression, you need to provide the functionId parameter , which specifies the operation. Use values from the workbook.ExpressionType enum for this parameter. The parameters parameter is optional and represents the parameters or operands for the function. Some functions don't need extra 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

General Notices