1

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?

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

2 Answers 2

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])
0
-1

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

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

Your Answer

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

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