SpssDimension Class (Python)

The SpssDimension class provides access to a pivot table's dimensions. A pivot table can have three types of dimensions: column dimensions, row dimensions, and layer dimensions. Using an SpssDimension object you can obtain the name of a dimension, change the current category, or pivot the dimension.

Table Dimensions

The following is an illustration of the three types of dimension in a pivot table. To see the pivot table with all its labels (as shown in the figure), double-click it and select View>Show All from the menus in the pivot table editor.

To display the pivot trays (if they are not on the screen), select Pivot >Pivoting Trays from the menus.

Getting an SpssDimension Object

You get an SpssDimension object from the GetColumnDimension, GetLayerDimension, or GetRowDimension method of an SpssPivotMgr object. The SpssPivotMgr object is obtained from the SpssPivotTable object. For example, the following gets an SpssDimension object for the row dimension with index 1:

SpssPivotMgr = SpssPivotTable.PivotManager()
SpssDimension = SpssPivotMgr.GetRowDimension(1)

Example

This example assumes that PivotTable is an SpssPivotTable object and moves the "Statistics" row dimension to the first column dimension.

PivotManager = PivotTable.PivotManager()
# Search for the row dimension named "Statistics" and pivot it to 
# the first column dimension.
for i in range(PivotManager.GetNumRowDimensions()): 
    RowDim = PivotManager.GetRowDimension(i)
    if RowDim.GetDimensionName()  == "Statistics":
        RowDim.MoveToColumn(0)
        break