Pivot data dimensions

You can use data dimensions to define the data you want to display and analyze in the pivot. You can create data dimensions based on columns in the dataset, then specify the data dimensions when you define the axes in the pivot.

In this tutorial, we are interested in the data from two columns: Type and Posting Period. We use workbook.createDataDimensionItem(options) to create a data dimension item for each column. This method accepts an expression that represents the column from the dataset. To obtain this expression, use Dataset.getExpressionFromColumn(options) and provide the alias of the column.

After creating the data dimension items, we create data dimensions for each item. A data dimension can include multiple data dimension items, but in our case, we have only one item per dimension. Use workbook.createDataDimension(options) to create each data dimension.

          var typeItem = nWorkbook.createDataDimensionItem({
    label: 'Type',
    expression: dataset.getExpressionFromColumn({
        alias: 'Type'
    })
})

var postingPeriodItem = nWorkbook.createDataDimensionItem({
    label: 'Posting Period',
    expression: dataset.getExpressionFromColumn({
        alias: 'PostingPeriod'
    })
})

var typeDataDimension = nWorkbook.createDataDimension({
    items: [typeItem]
})

var postingPeriodDataDimension = nWorkbook.createDataDimension({
    items: [postingPeriodItem]
}) 

        

Related Topics

General Notices