Select to view content in your preferred language

Coded Value Domain: Assign multiple codes to a single description

203
5
3 weeks ago
ClintSteeves1
Occasional Contributor

Does anyone know of a more efficient way to set up a coded value domain where numerous code values can represent a single description? Here's a snippet to show what I have:

ClintSteeves1_0-1744299241124.png

What I'd like to see is something along the lines of:

CodeDescription
0-2Low Risk
3-5Medium Risk
6-8High Risk

 

or

CodeDescription
0, 1, 2Low Risk
3, 4, 5Medium Risk
6, 7, 8High Risk

 

The number that will be used to determine risk level is calculated from four other numerical fields, and although I recognize I could set up the script to assign values of 0, 1, or 2 based on those number ranges, it would be nice to not require a workaround like that. I'd like to maintain the actual calculated values, because a High Risk with level 6 is still of lower importance than a High Risk of level 8.

Obviously, this is working as-is, but I was just wondering if anyone had any suggestions for a situation like this where perhaps the code values can range from 0 to 100. Inputting a description for each one of those code values would be a tedious job, even using a script.

 

Thanks

0 Kudos
5 Replies
DavidSolari
MVP Regular Contributor

If you make good use of the script tool parameter types this can be an efficient script tool. I've attached a tool with no code to execute but the parameters and validation already done, this illustrates how you can quickly gather a bunch of code ranges and their associated descriptions, for both new and existing domains.

0 Kudos
ClintSteeves1
Occasional Contributor

I'll check that out, thanks

0 Kudos
Robert_LeClair
Esri Esteemed Contributor

So I'm thinking a calculation attribute rule would be possible in this scenario.  The arcade code block in building the attribute rule would be something like this:

var code = $feature.Code;
var description = When(
code == 0 || code == 1 || code == 2, "Low Risk",
code == 3 || code == 4 || code == 5, "Medium Risk",
code == 6 || code == 7 || code == 8, "High Risk",
"Other"
);
return description;

You can make it an immediate calculation rule so when an editor types in the value 1 for the code field, the attribute rule triggers and calculates the Description field to be "low risk".  Caveat here - I'm not an arcade guru so the script may need some tweaking.

0 Kudos
DavidSolari
MVP Regular Contributor

This stores the code in one field and the description in another, which is different from having a coded-value domain on an integer field. Not strictly wrong, but not as useful as a proper field in my experience.

0 Kudos
Robert_LeClair
Esri Esteemed Contributor

True.  Just another way of looking at the question I suppose.

0 Kudos