laptop and a wrench

Bug

The AND operator does not work as expected in an advanced label expression.

Last Published: April 16, 2015 ArcGIS for Desktop
Bug ID Number BUG-000084817
SubmittedJanuary 27, 2015
Last ModifiedJanuary 19, 2021
Applies toArcGIS for Desktop
Version found10.1
Operating SystemWindows
Operating System Version8.1
StatusWill Not Be Addressed

Additional Information

We apologize that we were unable to address this issue within the current product support cycle.  If the issue continues to affect your work in a supported release, please contact Technical Support.

Workaround

Rather than using the AND operator in the label expression, create multiple Label Classes (one for each condition), use the SQL Query option to select features that meet the initial expression (such as Yes or No), and then use a simplified version of the expression to label the features. This allows users to break down the complex label expression and bypass the AND operator by working with multiple labels classes instead. For example: Original Expression: Function FindLabel ([YesNo], [ColorOption]) if ([YesNo] = "YES" AND [ColorOption] = "Red") then FindLabel = [YesNo] & vbNewLine & [ColorOption] elseif ([YesNo] = "NO" AND [ColorOption] = "Red") then FindLabel = [ColorOption]& vbNewLine &[YesNo]end ifEnd FunctionLabel Class one Yes:1. Open the layer Properties and click on the Labels tab2. Select “Define classes of features and label each class differently” form the Method dropdown3. Rename the current class to an appropriate name. 4. Click on the SQL Query… button - This allows users to set a query on the layer so that those features meeting this argument are the only ones shown with this label style5. Specify the SQL Query to be used for this label class and click OK- Example: SUBTYPE_YN = YES6. Click on the expression button and build the expression for this particular class and click OKFunction FindLabel ([YesNo], [ColorOption]) if ([ColorOption] = "Red") then FindLabel = [YesNo] & vbNewLine & [ColorOption]end ifEnd FunctionLabel Class two No:1. Click the Add… button to add the second label class.2. Give the new label class an appropriate name. In this case, use SUBTYPE_CD 2 because that is what this class grouped by.3. Click on the SQL Query… button 4. Specify the SQL Query to be used for this label class and click OK- Example: SUBTYPE_YN = NO5. Click on the expression button and build the expression for this particular class and click OKFunction FindLabel ([YesNo], [ColorOption]) if ([ColorOption] = "Red") then FindLabel = [ColorOption] & vbNewLine & [YesNo]end ifEnd FunctionThe first label class only label features that match the YES SQL Query and the second will only label those that match the NO SQL Query.

Steps to Reproduce

Bug ID: BUG-000084817

Software:

  • ArcGIS for Desktop

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options

Discover more on this topic