Insert Method (Python)
.Insert(i,place,dimName,hideName, hideLabels). Inserts
row, column, and layer dimensions into a pivot table. You use
this method, or the Append method, to create the dimensions associated
with a custom pivot table. The argument i specifies the position
within the dimensions of that type (row, column, or layer). The first
position has index 1 and defines the innermost dimension of that type
in the displayed table. Successive integers specify the next innermost
dimension and so on. The argument place specifies the type
of dimension: spss.Dimension.Place.row
for a row
dimension, spss.Dimension.Place.column
for a column
dimension, and spss.Dimension.Place.layer
for a layer
dimension. The argument dimName is a string that specifies
the name used to label this dimension in the displayed table. Each
dimension must have a unique name. The argument hideName specifies
whether the dimension name is hidden--by default, it is displayed.
Use hideName=True
to hide the name. The argument hideLabels specifies
whether category labels for this dimension are hidden--by default,
they are displayed. Use hideLabels=True
to hide category
labels.
- The argument i can take on the values 1, 2, ... , n+1
where n is the position of the outermost dimension (of the
type specified by place) created by any previous calls to
Append
orInsert
. For example, after appending two row dimensions, you can insert a row dimension at positions 1, 2, or 3. You cannot, however, insert a row dimension at position 3 if only one row dimension has been created. - The order in which dimensions are created (with the
Append
orInsert
method) determines the order in which categories should be specified when providing the dimension coordinates for a particular cell (used when Setting Cell Values or adding Footnotes). For example, when specifying coordinates using an expression such as(category1,category2)
, category1 refers to the dimension created by the first call toAppend
orInsert
, and category2 refers to the dimension created by the second call toAppend
orInsert
.Note: The order in which categories should be specified is not determined by dimension positions as specified by the argument i.
Example
table = spss.BasePivotTable("Table Title",
"OMS table subtype")
rowdim1=table.Append(spss.Dimension.Place.row,"rowdim-1")
rowdim2=table.Append(spss.Dimension.Place.row,"rowdim-2")
rowdim3=table.Insert(2,spss.Dimension.Place.row,"rowdim-3")
coldim=table.Append(spss.Dimension.Place.column,"coldim")

Examples of using the Insert
method are most easily
understood in the context of going through the steps to create a pivot
table. See the topic General Approach to Creating Pivot Tables (Python) for more information.