I'm filling in some missing attributes in a feature layer using 'calculate field' and I tried:
and this works, kind of. Empty fields gets filled in with '3' but any field already filled are emptied and <null> afterwards.
So for the moment I have:
which covers all possible values (in the coded value domain on this attribute). This works but is cumbersome.
What I would like to do is something like
How can I achieve this ... else do nothing ... ?
Thanks in advance for your time.
Bert Kraan
Solved! Go to Solution.
Hi Bert,
You can simply add the line "return $feature.verharding" to the else clause, which means for all other values it will just return the existing value.
Note, a better way to do this would be to use the IIF arcade function detailed here: Logical Functions | ArcGIS for Developers to do it in one line!
Hi Bert,
You can simply add the line "return $feature.verharding" to the else clause, which means for all other values it will just return the existing value.
Note, a better way to do this would be to use the IIF arcade function detailed here: Logical Functions | ArcGIS for Developers to do it in one line!
Hi, Bert
Guess the easiest will be to select all null values using Select by attributes, and then run the calculation using your initial code on the selected set.
Alternatively, you may send the value to the field calculator using:
Hi Bert Kraan,
I was actually going to come up with the first solution given by Joshua Sharp-Heward, but from the same answer I learned about the IIf() function.
That's why it is so good to follow this forum, to learn a little every day (very kaizen!).
So, to wrap up:
Simple solution | One line solution |
---|---|
|
|
HTH,
Egge-Jan
Long out of date, but thanks to you and @JoshuaSharp-Heward for mentioning IIF statements. I was able to greatly streamline some of my attribute rules using this newfound knowledge!
This is a good solution, but it does change the edit date on the records as if they were actually calculated. I wonder if there is another way to do this (when selecting a set first is not an option)?
I am pretty sure you are out of luck, and it isn't just an Arcade limitation. Calculate Field has to return something for each record, there is no way to tell Calculate Field to stop processing the current record and move onto the next.