I have two optional parameters in my ArcMap model (City and date) and I want to use the tool calculate a value to create an expression that will give me a boolean (true-false).

I want the code to return me a true statement if a city and a date have been entered by the user of the model and false if only one of the two have been requested (ex: city=Chicago and no date has been entered).

So far, I have this :

expression :

x("%City%", "%Date%")

Code :

def x(City, Date)
if City is not None and Date is not None:
returns True
return False

Type: Boolean


1 Answer 1


So what is your question? So far you state what you have done but not said what the issue is!

If it is not working then one issue may be your code block, its missing a colon at end of the first line and your code is incorrectly indented. Python will fail on that.

But I feel if the outcome is to simply ensure that your two inputs have been entered why not make them required model parameters then you would never be in this situation in needing to test if city and date are filled in? Required parameters must have a value whilst optional parameters can be skipped when you run a model tool.

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.