Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
    
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 '13 at 23:07
up vote 2 down vote accepted

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])
share|improve this answer

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

share|improve this answer

We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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