How do I concatenate fields and get results of what I see in the attribute table and not the coded values in the new field created ?

675
2
09-30-2021 03:36 PM
markross
New Contributor

 I have created a new field in the attribute table Called "new_labes". 

I then right-click on 'new_labels' to open the calculate field tool I  then concatenate other fields such as SAF or SRM in the attribute table.  the result is giving me the Coded name and not the description as it was previously was viewed in the attribution table for  SAF or SRM. 

EX:

Before : SAF=pine tree and         After: In new_labels SAF value is seen as 001

I did notice that SAF does have a domain type as coded value domain which 000 = pine tree

how do I concatenate fields and get results of what I see in the attribute table and not the coded values in the new field created new_labels?

 

0 Kudos
2 Replies
UriGilad_EsriAu
Esri Contributor

Hi @markross,

The GDB's domains have a code and a description. The calculator is grabbing the code instead of the description.

In the field calculator, using Python 3 as Expression Type, use the following code (replace the values in red with the relevant values):

new_labels 

getDomain(!SourceField1!, !SourceField2!, 'DomainName')

 

In the Code Block:

def getDomain(source1FieldCode,source2FieldCode,DomainName):
    gdb = r"yourGDB.gdb"
    dom_desc = [d.codedValues for d in arcpy.da.ListDomains(gdb) if d.name == DomainName][0]
    for code in dom_desc.items():
        if code[0]==source1FieldCode:
            domDescription1 = code[1]
        if code[0]==source2FieldCode:
            domDescription2 = code[1]
    Concat = domDescription1+domDescription2
    return Concat

You can find the domain name in the GDB's domain table.

Hope this helps, 

Uri

If this answer solved your question or if you found it helpful please mark it accordingly to help others who have the same question.
markross
New Contributor

Thanks, Uri

The problem I'm still having is how do I use multiple domains? If Field one has one domain ex: "EV_SRM_COVER_TYPE" and field two has a separate domain listed ex: "EV_SAF_COVER_TYPE" in GDB.

Field 1 = !SRM_COVER_TYPE! 

Field 2 = !SAF_COVER_TYPE!

the result is still 000-111 after I concatenate but I need the descriptions instead of the code

0 Kudos