I'm looking for an arcade expression for arcgis pro symbology. Involves the Asset ID field to symbolise based on text within an asset ID.

Say if the asset ID contains C2 then blue (for instance), or if the asset ID contains C1, C3 or GAS, so on and so forth. Imagine a treatment plant with lots of pipes of different colors all based off different common text within the asset ID.

How would the arcade expression look if trying to achieve this?

Maybe another way of putting it would be: What would the symbology expression be if i wanted; 5 different colors based off different text in the asset ID field: "C1", "C2", "C3", "GAS" and "AIR"

Im thinking the answer to my question might involve the "Contains ()" function. How does a expression look when using the contains function.

I am using the code below as a symbology expression with limited success.

var disp_txt = $feature.ASSET_ID

if (Find("-C2-", disp_txt, 0)>-1) {
    return "C2";
} else if (Find("-C3-", disp_txt, 0)>-1) {
    return "C3";
} else if (Find("-C1-", disp_txt, 0)>-1) {
    return "C1";
} else if (Find("GAS", disp_txt, 0)>-1) {
    return "BIOGAS";
} else if (Find("RS", disp_txt, 0)>-1) {
    return "RAW SLUDGE";
} else if (Find("DSL", disp_txt, 0)>-1) {
    return "DSL";
} else if (Find("AIR", disp_txt, 0)>-1) {
    return "AIR";
} else if (Find("-G-", disp_txt, 0)>-1) {
    return "GRIT";
} else if (Find("PD", disp_txt, 0)>-1) {
    return "PLANTDRAIN";
} else if (Find("TD", disp_txt, 0)>-1) {
    return "TANKDRAIN";
  • You talk about symbology yet the code snippet you show appears to suggest you are trying to create labels, which I assume you want to colour differently? Please clarify.
    – Hornbydd
    Commented Apr 5, 2023 at 22:54
  • see this page
    – Hornbydd
    Commented Apr 5, 2023 at 23:22
  • No sorry that did not help, as i would prefer to use the ribbon for size, font etc... I have found it easier to create labels based off the symbology once the symbology is set up properly. I would like to return to the symbology code issue, can you help with this. Commented Apr 5, 2023 at 23:37
  • So for your asset_id field, taking the sample code you have for AIR, you are searching within the string for AIR and if found you want to return the text "AIR". So first question what is a typical example of what asset_id holds? Is it literally the text AIR or or air, or is it part of a larger bit of text such as "I like hot air balloons"? Because if it just the text AIR, GRIT, TANKDRAIN for example then I think you are over thinking things and a simple unique values symbology is all that is required?
    – Hornbydd
    Commented Apr 6, 2023 at 14:20
  • sample of asset ID's are:CL40-A-PVC-16 (AIR), CL375-C1-GV-02 (C1), CL1200-TD-PE-05 (TANKDRAIN) and so on, there is a letter code embedded in the middle of the asset ID. Commented Apr 11, 2023 at 19:17

3 Answers 3


Although a workable solution was found, large else if blocks can usually be replaced with cleaner functions, regardless of the language. For ArcGIS Arcade, two functions that can often replace large else if blocks are Decode and When.

Looking at the sample data in the question comments, the asset IDs appear regular enough in structure that using Split and Decode can be used to replace else if:

var txt = $feature.ASSET_ID;
  Split(txt, '-')[1],
  'C2', 'C2',
  'C3', 'C3',
  'C1', 'C1',
  'GAS', 'BIOGAS',

I think you are getting confused with what the expression does. Below is some data, simply set to unique values on a field called regions:


I click on the expression button and create the following expression, similar to what you are doing with your asset ID field

Expression builder

Notice the classes change to the output text created by the expression:


Here in lies the possible confusion you have, the expression changes only the class names, it has nothing to do with the symbology. YOU change the symbology by simply double clicking on the coloured dots (the brown/green in my example below) and change them to what ever you want.

The expression builder has no capability in altering the symbology that is applied to the class that the expression is outputting. You set that manually. You can alter symbology programmatically through something like the CIM module, but that requires advance understanding of the object model and programming in python.


Here is your solution in practice:

var txt = $feature.ASSET_ID
if (Find("-C2-", txt, 0)>-1) {return "C2";}
else if (Find("-C3-", txt, 0)>-1) {return "C3";}
else if (Find("-C1-", txt, 0)>-1) {return "C1";}
else if (Find("GAS", txt, 0)>-1) {return "BIOGAS";}
else if (Find("RS", txt, 0)>-1) {return "RAW SLUDGE";}

Looks pretty similar to the original code submitted at the start, so i was on the right track. I think some confusion, lay in the assumption i had attribute data that i could modify. This was protected data (could not add fields) and only had asset ID which is a unique reference number.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.