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.

In my model, I have a Calculate Field which will populate the field with a certain integer (in this case, 0). I've added an optional integer model parameter Start ID, where the user can specify the integer if they want.

Model

If Start ID is given a value by the user, this value must be used as the expression for Calculate Field, else Expression must be used. Since the tool can only take one expression as an input, would I have to create a copy of the Calculate Field with Start ID as the expression, and use Merge Branch with an if statement to test which branch must run i.e. the Start ID branch only runs if it has a value, else run the Expression branch?

share|improve this question

1 Answer 1

up vote 3 down vote accepted

I think this can be done much more simply using a model like this:

enter image description here

where the If/Then logic is part of the Calculate Field tool:

enter image description here

Think of the newValue = 123 + 456 part being your Expression.

In my test this will calculate a field to be 479 (= 123 + 456) if nothing is entered by the user for Start ID (which is an Optional parameter) or whatever integer value they enter otherwise.

share|improve this answer
    
Simple and efficient answer. Thank you! –  Arabella Oct 26 '12 at 8:35

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.