workbook.createPivot(options)
Method Description |
Creates a pivot. A pivot is a workbook component that enables you to pivot your dataset query results by defining measures and dimensions, so that you can analyze different subsets of data. A pivot definition is based on an underlying dataset and can include an ID, a name, a row axis, a column axis, conditional/limiting filters, and filter expressions. |
Returns |
|
Supported Script Types |
Server scripts For more information, see SuiteScript 2.x Script Types. |
Governance |
None |
Module |
|
Sibling Module Members |
|
Since |
2020.2 |
Parameters
The options
parameter is a JavaScript object.
Parameter |
Type |
Required / Optional |
Description |
---|---|---|---|
|
optional |
The set of conditional filters or limiting filters that are applied to the pivot. When multiple filters are defined, they are aggregated together to form a single compounded filter. |
|
|
required |
The column axis (X-axis) for the pivot. This includes the fields and measures that are used on the column axis, as well as sorting behavior that is applied to the axis fields and measures. |
|
|
required |
The underlying dataset that the pivot is based on. A pivot can include only the data (fields) that are included in the dataset. |
|
|
optional |
The simple, non-aggregated value-based filters for the pivot. |
|
|
string |
required |
The ID of the pivot. |
|
string |
required |
The name of the pivot. |
|
required |
The report styles for the pivot. |
|
|
required |
The row axis (Y-axis) for the pivot. This includes the fields and measures that are used on the column axis, as well as sorting behavior that is applied to the axis fields and measures. |
Syntax
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. Also see Full scripts in the Tutorial: Creating a Workbook Using the Workbook API topic.
// Add additional code
...
// Create a basic PivotDefinition
var myPivotDefinition = workbook.createPivotDefinition({
name: 'My Pivot Definition',
id: '_myPivotDefinition',
rowAxis: myRowPivotAxis,
columnAxis: myColumnPivotAxis,
dataset: myDataset
});
// Create a comprehensive PivotDefinition with Expressions
var myPivotDefinition = workbook.createPivotDefinition({
name: 'My Pivot Definition',
id: '_myPivotDefinition',
rowAxis: myRowPivotAxis,
columnAxis: myColumnPivotAxis,
dataset: myDataset,
filterExpressions: [myExpression]
});
// Create a comprehensive PivotDefinition with LimitingFilters
var myPivotDefinition = workbook.createPivotDefinition({
name: 'My Pivot Definition',
id: '_myPivotDefinition',
rowAxis: myRowPivotAxis,
columnAxis: myColumnPivotAxis,
dataset: myDataset,
filterExpressions: [myExpression],
aggregationFilters: [myLimitingFilter]
});
// Create a comprehensive PivotDefinition with ConditionalFilters
var myPivotDefinition = workbook.createPivotDefinition({
name: 'My Pivot Definition',
id: '_myPivotDefinition',
rowAxis: myRowPivotAxis,
columnAxis: myColumnPivotAxis,
dataset: myDataset,
filterExpressions: [myExpression],
aggregationFilters: [myConditionalFilter]
});
...
// Add additional code