How to set range in arcgis model builder

1165
9
01-16-2020 10:18 AM
AyokunleAdebisi1
New Contributor III

I am builder model that users will be able to select  values of year in range i.e 5 or 10years interval. The Year picklist will look like this in the tool. How can I do this in ArcGIS model builder ?

0 Kudos
9 Replies
curtvprice
MVP Esteemed Contributor

You could create a text string variable, set it as a parameter, and in the Model Options parameters, use a filter to create the list of choices.

Then use the Calculate Value tool to convert that string to a SQL expression, like this:

"YEAR >= {} AND YEAR <= {}".format("%Year Range%"[0:4], "%Year Range%"[5:])

The above expression would yield for your first choice "1967-1971":

YEAR >= 1967 AND YEAR <= 1971
AyokunleAdebisi1
New Contributor III

Thanks for your reply @Curtis Price I did as you instructed and it worked, but however i did same for Months in the year i.e instead of using YEAR, I use MONTH 

MONTH >= JANUARY AND MONTH <= APRIL

But it shows empty output, what could be wrong? or it can only be used for numeric but not text or what could be the issue?
0 Kudos
AyokunleAdebisi
New Contributor III

I think it is working but it selects alphabetically i.e  if I select from April it will select  all values of month from A-S, but if I select from January to April, it returns null because J does come before A.. how can i solve this to make it select January to April or September to December to return a value.

0 Kudos
AyokunleAdebisi
New Contributor III

I think it is working but it selects alphabetically i.e  if I select from April it will select  all values of month from A-S, but if I select from January to April, it returns null because J does not come before A.. how can i solve this to make it select January to April or September to December to return a value.@Curtis Price .

0 Kudos
DavidPike
MVP Frequent Contributor

A value list filter for the parameter?

0 Kudos
AyokunleAdebisi
New Contributor III

if i understand your question...Yes 

0 Kudos
DavidPike
MVP Frequent Contributor
AyokunleAdebisi
New Contributor III

I am not well skilled in python...it would be best to it in modelbuilder if possible..Thanks

0 Kudos
AyokunleAdebisi
New Contributor III

Thanks.

0 Kudos