I am trying to build a tool where the end user can run a model and make a selection from a feature class based on 3 different fields, calculate the total shape length, & export the results to a csv file. I have everything else figured out except for one part. I want the user be able to make a selection based on all three fields or based on one , two, or all three fields without them having to edit the selection query.
As you probably guess when I don't populate one of the user defined parameters it pops up with an error. I think the way to do this would be to use the "calculate value"in model builder and use Python to build a sql expression and use that expression for the selection. I was thinking of having 3 user defined parameters with drop down list of field values and using inline variable substitution in the calculate value tool to create a sql expression based on what the user defined in the parameters.
This is the expression I have right now for them to select using all three field values:
"DISTRICT" = '%District%' AND "SURFACE" = '%Surface%' AND "JURISD" = '%Jurisdiction%'
I have a basic understanding of Python. Any help or suggestions would be greatly appreciated. Thanks!