AnsweredAssumed Answered

Finding the max of a field and adding 1

Question asked by twoodfield_DawoodGIS on Mar 31, 2020
Latest reply on Mar 31, 2020 by twoodfield_DawoodGIS

I'm trying to write an expression to use in model builder that if the field is 0, it will find the max for the field and add 1 to it. What I have so far is "(max([!Version!])+1) if !Version! ==0 else !Version!". The version field has integers from 0 to 5 right now. The dataset gets appended to periodically and we want to update the version to be the next number. Ideally, we would want the expression to find the max and add 1 to it but only add that value to rows with a Version value of 0 or null. 


1. Find the max for the Version field

2. Calculate only features with the version values 0 (or prefereably null) with the max value +1


A select by attributes could be used to only calc the rows we want but then it will only get the max of what is selected and not the whole dataset. I tried to use the Calculate Value tool in modelbuilder to just get the max value but it wasn't working correctly.


Thank you,