ArcGIS for Desktop

  • Documentation
  • Pricing
  • Support

  • My Profile
  • Help
  • Sign Out
ArcGIS for Desktop

ArcGIS Online

The mapping platform for your organization

ArcGIS for Desktop

A complete professional GIS

ArcGIS for Server

GIS in your enterprise

ArcGIS for Developers

Tools to build location-aware apps

ArcGIS Solutions

Free template maps and apps for your industry

ArcGIS Marketplace

Get apps and data for your organization

  • Documentation
  • Pricing
  • Support
Esri
  • Sign In
user
  • My Profile
  • Sign Out

Help

  • Home
  • Get Started
  • Map
  • Analyze
  • Manage Data
  • Tools
  • More...

Pivot Table

Available with Advanced license.

  • Summary
  • Illustration
  • Usage
  • Syntax
  • Code sample
  • Environments
  • Licensing information

Summary

Creates a table from the input table by reducing redundancy in records and flattening one-to-many relationships.

Illustration

Pivot Table illustration

Usage

  • This tool is typically used to reduce redundant records and flatten one-to-many relationships.

  • If the Pivot Field is a text field, its values must begin with a character (for example, a2) and not a number (for example, 2a). If the value of the first record begins with a number, all the output values will be 0.

  • If the Pivot Field is a numeric type, its value will be appended to its original field name in the output table.

  • The Input Field(s) parameter's Add Field button is used only in ModelBuilder to access and load the expected fields of a preceding process that has not yet been run into the Input Field(s) list so you can complete the Pivot Table dialog box and continue to build the model.

  • The number of fields in the output table is determined by the number of input fields you choose, plus one field for each unique Pivot Field value. The number of records in the output table is determined by the unique combination of values between your chosen input fields and the pivot field.

Syntax

PivotTable_management (in_table, fields, pivot_field, value_field, out_table)
ParameterExplanationData Type
in_table

The table whose records will be pivoted.

Table View
fields
[fields,...]

The fields that define records to be included in the output table.

Field
pivot_field

The field whose record values are used to generate the field names in the output table.

Field
value_field

The field whose values populate the pivoted fields in the output table.

Field
out_table

The table to be created.

Table

Code sample

PivotTable Example (Python Window)

The following Python Window script demonstrates how to use the PivotTable function in immediate mode.

import arcpy
from arcpy import env

env.workspace = "C:/data"
arcpy.PivotTable_management("attributes.dbf", "OwnerID", "AttrTagNam", "AttrValueS", "C:/output/attribPivoted.dbf")
PivotTable Example 2 (Stand-alone Python Script)

The following Python script demonstrates how to use the PivotTable function in a stand-alone script.

# Name: PivotTable_Example2.py
# Description: Pivot the attributes table by the specified fields
# Author: ESRI

# Import system modules
import arcpy
from arcpy import env

# Set workspace
env.workspace = "C:/data"

# Set local variables
in_table = "attributes.dbf"
fields = "OwnerID"
pivot_field = "AttrTagNam"
value_field = "AttrValueS"
out_table = "C:/output/attribPivot.dbf"

# Execute PivotTable
arcpy.PivotTable_management(in_table, fields, pivot_field, value_field, out_table)

Environments

  • Current Workspace
  • Output CONFIG Keyword
  • Scratch Workspace

Licensing information

  • ArcGIS for Desktop Basic: No
  • ArcGIS for Desktop Standard: No
  • ArcGIS for Desktop Advanced: Yes

Related topics

  • An overview of the Table toolset

ArcGIS for Desktop

  • Home
  • Documentation
  • Pricing
  • Support

ArcGIS Platform

  • ArcGIS Online
  • ArcGIS for Desktop
  • ArcGIS for Server
  • ArcGIS for Developers
  • ArcGIS Solutions
  • ArcGIS Marketplace

About Esri

  • About Us
  • Careers
  • Insiders Blog
  • User Conference
  • Developer Summit
Esri
Tell us what you think.
© Copyright 2016 Environmental Systems Research Institute, Inc. | Privacy | Legal