Calculate Value (ModelBuilder)

Summary

Returns a value based on a specified Python expression.

Learn how Calculate Value works in ModelBuilder

Usage

  • This tool is only available from ModelBuilder for use in models. The tool is not available from the Geoprocessing pane or from Python.

  • The Expression parameter only supports Python expressions. Other scripting languages are not supported.

  • Use the Expression parameter for short one line expressions. Use the Code Block parameter for more complicated expressions, such as multiline calculations or logical operations (if, then). The Code Block parameter cannot be used on its own; it must be used in conjunction with the Expression parameter.

    See examples of using the Expression parameter.

  • Variables created in ModelBuilder can be used by this tool, but they cannot be used directly in the Expression parameter. To use a variable in the expression, enclose the variable name in percent signs (%) or double-click the variable name in the Variables list to add it to the Expression parameter.

  • To use a Python function in an expression, double-click a function in the Functions list to add it to the Expression parameter.

    Calculate Value Tool with Variable and Functions list
  • You cannot access model variables in the Code Block parameter. These variables must be passed to the code block from the expression. To do this, create a function definition in the Code Block parameter and reference the definition in the Expression parameter.

    See examples of using the Code Block parameter.

  • The Data Type parameter is used in ModelBuilder to help chain the output of this tool with other tools. For example, if you use this tool to calculate a distance for use as input to the Buffer Distance parameter of the Buffer tool, specify Linear Unit for the Data Type parameter value.

    See examples of using the Data Type parameter.

  • In Python, proper indentation is part of the syntax. The indentation level (two spaces or four spaces) does not matter as long as it is consistent throughout the code block.

  • Note:

    When writing equivalent Python scripts, use standard Python statements instead of using this tool.

Parameters

LabelExplanationData Type
Expression

The Python expression that will be evaluated.

Use the Expression parameter for short one line expressions. Use the Code Block parameter for more complicated expressions, such as multiline calculations or logical operations (if, then). The Code Block parameter cannot be used on its own; it must be used in conjunction with the Expression parameter.

SQL Expression
Code Block
(Optional)

A Python code block. The code in the code block must be referenced in the Expression parameter.

String
Data type
(Optional)

Specifies the data type of the return value of the Python expression. This parameter helps chain Calculate Value with other tools.

  • 3D Object Feature Layer3D Object Feature Layer
  • Address LocatorAddress Locator
  • Analysis Cell SizeAnalysis Cell Size
  • Annotation LayerAnnotation Layer
  • Any ValueAny Value
  • ArcMap DocumentArcMap Document
  • Areal UnitAreal Unit
  • BIM File WorkspaceBIM File Workspace
  • BooleanBoolean
  • Building Discipline LayerBuilding Discipline Layer
  • Building Scene Discipline LayerBuilding Scene Discipline Layer
  • Building LayerBuilding Layer
  • Building Scene LayerBuilding Scene Layer
  • CAD Drawing DatasetCAD Drawing Dataset
  • Calculator ExpressionCalculator Expression
  • Catalog LayerCatalog Layer
  • Catalog RootCatalog Root
  • Cell SizeCell Size
  • Cell Size XYCell Size XY
  • Composite LayerComposite Layer
  • CompressionCompression
  • Coordinate SystemCoordinate System
  • Coordinate Systems FolderCoordinate Systems Folder
  • CoverageCoverage
  • Coverage Feature ClassCoverage Feature Class
  • Data ElementData Element
  • Data FileData File
  • Database ConnectionsDatabase Connections
  • DatasetDataset
  • DateDate
  • dBASE TabledBASE Table
  • DecimateDecimate
  • Diagram LayerDiagram Layer
  • Dimension LayerDimension Layer
  • Disk ConnectionDisk Connection
  • DoubleDouble
  • Elevation Surface LayerElevation Surface Layer
  • Encrypted StringEncrypted String
  • EnvelopeEnvelope
  • Evaluation ScaleEvaluation Scale
  • ExtentExtent
  • Extract ValuesExtract Values
  • Feature ClassFeature Class
  • Feature DatasetFeature Dataset
  • Feature LayerFeature Layer
  • Feature SetFeature Set
  • FieldField
  • Field InfoField Info
  • Field MappingsField Mappings
  • FileFile
  • FolderFolder
  • Formulated RasterFormulated Raster
  • Fuzzy FunctionFuzzy Function
  • GeoDataServerGeoDataServer
  • GeodatasetGeodataset
  • Geometric NetworkGeometric Network
  • Geostatistical LayerGeostatistical Layer
  • Geostatistical Search NeighborhoodGeostatistical Search Neighborhood
  • Geostatistical Value TableGeostatistical Value Table
  • GlobeServerGlobeServer
  • GPServerGPServer
  • GraphGraph
  • Graph Data TableGraph Data Table
  • Graphics LayerGraphics Layer
  • Group LayerGroup Layer
  • Horizontal FactorHorizontal Factor
  • Image ServiceImage Service
  • IndexIndex
  • INFO ExpressionINFO Expression
  • INFO ItemINFO Item
  • INFO TableINFO Table
  • Internet Tiled LayerInternet Tiled Layer
  • KML LayerKML Layer
  • LAS DatasetLAS Dataset
  • LAS Dataset LayerLAS Dataset Layer
  • LayerLayer
  • Layer FileLayer File
  • LayoutLayout
  • LineLine
  • Linear UnitLinear Unit
  • LongLong
  • M DomainM Domain
  • MapMap
  • Map ServerMap Server
  • Map Server LayerMap Server Layer
  • Mosaic DatasetMosaic Dataset
  • Mosaic LayerMosaic Layer
  • NeighborhoodNeighborhood
  • Network Analyst Class FieldMapNetwork Analyst Class FieldMap
  • Network Analyst Hierarchy SettingsNetwork Analyst Hierarchy Settings
  • Network Analyst LayerNetwork Analyst Layer
  • Network Data SourceNetwork Data Source
  • Network DatasetNetwork Dataset
  • Network Dataset LayerNetwork Dataset Layer
  • Network Travel ModeNetwork Travel Mode
  • Oriented Imagery LayerOriented Imagery Layer
  • Parcel FabricParcel Fabric
  • Parcel Fabric for ArcMapParcel Fabric for ArcMap
  • Parcel Fabric Layer for ArcMapParcel Fabric Layer for ArcMap
  • Parcel LayerParcel Layer
  • PointPoint
  • PolygonPolygon
  • Projection FileProjection File
  • PyramidPyramid
  • RadiusRadius
  • Random Number GeneratorRandom Number Generator
  • Raster BandRaster Band
  • Raster Calculator ExpressionRaster Calculator Expression
  • Raster CatalogRaster Catalog
  • Raster Catalog LayerRaster Catalog Layer
  • Raster Data LayerRaster Data Layer
  • Raster DatasetRaster Dataset
  • Raster LayerRaster Layer
  • Raster StatisticsRaster Statistics
  • Raster TypeRaster Type
  • Record SetRecord Set
  • Relationship ClassRelationship Class
  • RemapRemap
  • ReportReport
  • Route Measure Event PropertiesRoute Measure Event Properties
  • Scene LayerScene Layer
  • SemivariogramSemivariogram
  • ServerConnectionServerConnection
  • ShapefileShapefile
  • Spatial ReferenceSpatial Reference
  • SQL ExpressionSQL Expression
  • StringString
  • String HiddenString Hidden
  • TableTable
  • Table ViewTable View
  • Terrain LayerTerrain Layer
  • Text FileText File
  • Tile SizeTile Size
  • Time ConfigurationTime Configuration
  • Time UnitTime Unit
  • TINTIN
  • TIN LayerTIN Layer
  • ToolTool
  • ToolboxToolbox
  • Topo FeaturesTopo Features
  • TopologyTopology
  • Topology LayerTopology Layer
  • Trace NetworkTrace Network
  • Trace Network LayerTrace Network Layer
  • Trajectory LayerTrajectory Layer
  • Transformation FunctionTransformation Function
  • Utility NetworkUtility Network
  • Utility Network LayerUtility Network Layer
  • VariantVariant
  • Vector Tile LayerVector Tile Layer
  • Vertical FactorVertical Factor
  • Voxel LayerVoxel Layer
  • VPF CoverageVPF Coverage
  • VPF TableVPF Table
  • WCS CoverageWCS Coverage
  • Weighted Overlay TableWeighted Overlay Table
  • Weighted SumWeighted Sum
  • WMS MapWMS Map
  • WMTS LayerWMTS Layer
  • WorkspaceWorkspace
  • XY DomainXY Domain
  • Z DomainZ Domain
String

Derived Output

LabelExplanationData Type
Value

The calculated value.

Data Element; Layer; Table View

Environments

This tool does not use any geoprocessing environments.

Licensing information

  • Basic: Yes
  • Standard: Yes
  • Advanced: Yes

Related topics