I would like to add values from multiple fields in a shape file and display the result as a label

This is what I'm doing currently::

if ( [SwineGesBo] + [SwineSowLt] > 0) then 
    output = output & [SwineGesBo] + [SwineSowLt] & "Sows"

Unfortunately the code here only puts the two value together and does not sum them.

How can I do this?

  • In addition to the below comments, I believe your if statement might give you incorrect results. Try putting the ">0" outside the parentheses.
    – Fezter
    Commented Jan 17, 2013 at 23:07

2 Answers 2


From the Help button on the Label Expression dialog:

Field values are automatically cast to text strings. Therefore, if you wish to use a numeric value in an arithmetic operation, or when making a comparison, you will need to cast it back to a numeric data type.

In place of

[SwineGesBo] + [SwineSowLt]

try using

cint([SwineGesBo]) + cint([SwineSowLt])

Add and calculate a new field with the values summed, then call on this new field in the label expression.

  • Ok the concept makes sense to me. Could you give me an example of what this might look like? TIA
    – Seth_ia
    Commented Jan 17, 2013 at 21:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.