About Using Expressions in Style Definitions

You can use expressions as values for almost all style settings. Use the Expression Builder to style features using expressions based on both feature class attributes and on attributes of related features, or on any values that you calculate using attribute values.

Text Functions

Use the Expression Builder to create calculated properties that can be used for dynamic styling. The industry model provides two text functions.

TB_SQL—Use this text function to query attributes from a related feature class. The attributes can be used for styling. The SQL command must correspond to the following rules:

Note:

To test the SQL command, execute SELECT g.FID, (SQL command) FROM <feature class name> g. For example, use SQL Sheet to execute the command.

TB_VARIABLE

Use this text function to create a calculated text property that provides a user defined variable for thematic stylization. The variables are stored in the system table TB_VARIABLE. For each personal login, you can define such variables.

For example, in TB_VARIABLE, you define a variable BUILDING whose value represents the FID. In Display Manager you use the variable to style the building. To highlight a single building in the map, you enter the FID of the building in TB_VARIABLE. If you want to highlight another building, you need not modify the display model, but you can enter the new FID in TB_VARIABLE.

If, Lookup, and Range

Use these functions to define a theme for one display attribute, for example, line color or thickness. They work with multiple data types: string, real, integer, boolean, color, and date-time. Each parameter can be a constant or expression that evaluates to a string or numerical value.

If

If('Condition', TrueValue, FalseValue)

The ‘Condition’ parameter is a string containing any expression that evaluates to a Boolean value (essentially, a filter). This might be a single comparison, such as 'population > 1000', where ‘population’ is a feature property of the layer. ‘TrueValue’ and ‘FalseValue’ are expressions that are evaluated and returned when the condition is true or false, respectively. Both expressions must evaluate to the same data type (string or number).

This example could be used to rotate an upward-facing arrow symbol to indicate rising or falling populations: If('pop2005 > pop2000', 0.0, 180.0)

Lookup

Lookup(Expression, DefaultValue, Key1, Value1, … KeyN, ValueN)

This function implements a lookup table where each key is associated with a single value. ‘Expression’ is an expression that evaluates to a key (string or number). This key is compared to the remaining constant ‘Key#’ parameters to select the constant ‘Value#’ parameter that is to be returned. If the requested key is not found, ‘DefaultValue’ is returned. The ‘Expression’ and all ‘Key’ parameters must have the same data type, as must the ‘DefaultValue’ and all ‘Value#’ parameters. The number of key-value pairs is not fixed.

This example could be used to assign colors to parcels based on their zoning type:

Lookup(zoning, 0xff888888, 'Industrial', 0xffff0000, 'Commercial', 0xff00ff00, 'Residential', 0xff0000ff)

Range

The range function compares the ‘Expression’ key to a set of ranges, where a key matches a range if MIN <= KEY < MAX:

Range(Expression, DefaultValue, Min1, Max1, Value1, … MinN, MaxN, ValueN)

Ranges are specified by the ‘Min#’ and ‘Max#’ parameters, and each has an associated ‘Value#’ parameter. If the requested key does not match any of the provided ranges, ‘DefaultValue’ is returned. If ranges overlap, the first range that matches the key will be selected. The ‘Expression’ and all ‘Min’ and `Max’ parameters must have the same data type, as must the ‘DefaultValue’ and all ‘Value#’ parameters. The number of range-value sets is not fixed.

This example could be used to specify symbol size depending on city populations:

Range(population, 4.0, 100000, 1000000, 6.0, 1000000, 10000000, 8.0)