Hi Esri community,
I have two fields that represent different event categories, each denoting the year a given event category occurred.
I want to calculate a new field that will list the field name of the event type with the maximum value (latest year).
Is there any way I can do this?
Event_type1 ; Event_type2, last_event_type
1984 1972 event_type1
Thanks for any help!!
- Also, I posted this in the Python community because I thought there might be a script that could perform this action, but if there is a better geonet community for this question please let me know.
What do you want to happen if two events happen in the same year? Can you give an example row in your dataset?
If two events happen in the same year I would want the field to have the name of a third separate column.
Quickly off the top of my head something like this. Are you trying to do this in a field calculator or in a script?
Event_one = "Event_type1" Event_two = "Event_type2" Last_Event = "last_event_type" if Event_one > Event_two: Last_Event = "Event_type1" else: Last_Event = "Event_type2"
Thanks for this!!
Preferably in field calculator, but if a python script is the only way to do it, that will have to do.
I'd do it in field calculator with something along the lines Matt laid out, using a code block.
Try Calculating the field using Expression Type Python.
def Value(x,y): if (x > y): return "Event_type1" else: return "Event_type2"