Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I'm wanting to add together values from multiple fields in shp file and display the result as a the label here's what I'm looking at right now:

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

Unfortunately what I've wrote here only sticks the two value together and does not sum them together. Is what I'm wanting to do possible? And if so how whould I do it? TIA

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
add comment

2 Answers

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
    
Thanks! That works –  Seth_ia Jan 18 '13 at 14:00
add comment

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

share|improve this answer
    
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
add comment

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.