I have a field (WS_Type in the screenshot) that I want to use to calculate values based on the text within the field. The number of occurrences of each WS_Type in the field is not important, but the presence of each different type in the field is. Basically, I need to create an if/then statement that says, if this field contains "NRW" AND "Diversion", then it will get a score of X. If this field contains "NRW" OR "Spring" it will get a score of Y, etc. I'm not sure how to set up this if/then statement.
Create a new field for your output. Make sure it is string type.
Click Show Codeblock.
Write your code block/'Pre-Log Script Code' in python like this:
def func(input): if 'NRW' in input and 'Diversion' in input: return 'X' elif 'NRW' in input or 'Spring' in input: return 'Y' else: continue
Then use it on the field you created like this: