Select to view content in your preferred language

Use two fields for symbology on only one value

940
6
Jump to solution
04-03-2024 11:45 AM
MikhaylaB
Frequent Contributor

I have my symbology set to unique values with one field currently, and the outcome is MOSTLY what I want. They layer is symbolized by the "Type" field which splits it up based on the coded domain options that correspond to a department. One department is asking for only their data to be split up further by a second field. Is there a way to only change the symbology for this one value? 

Ex.

Maintenance

Horticulture

Storm Water

Storm Water Pre Storm

Storm Water Post Storm

Tags (2)
1 Solution

Accepted Solutions
MErikReedAugusta
Frequent Contributor

Another option is an Arcade script in your symbology.  The code below is mostly pseudocode, so you'll need to adapt it to your actual field names & the type value for 'Storm Water'.

 

if ($feature.typeField == 'Storm Water')
{
  return `${$feature.typeField} ${$feature.secondField}`
}
else
{
  return $feature.typeField
}

 

Also note: If you have a coded domain, the pseudo code above works exclusively with the raw codes, and not the alias.  Below is pseudocode for the alias:

 

if (DomainName($feature, 'typeField') = 'Storm Water')
{
  return `${DomainName($feature, 'typeField')} ${DomainName($feature, 'secondField')}`
}
else
{
  return DomainName($feature, 'typeField')
}

 

As an aside, if you aren't familiar with the backtick notation in Line 3, it's a way of writing your variables directly in-line with your formatting, similar to Python's f-strings.  Variables go in curly braces preceded by a dollar sign: ${variablehere}.  Anything else is treated as part of the string and is displayed as-is, including line breaks.

If your typeField is "Storm Water" and your secondField is "Foobar" then the result returned by line 3 would be "Storm Water Foobar"

View solution in original post

0 Kudos
6 Replies
marksm_macomb
Frequent Contributor

You could make two copies of the same layer, put a definition query on the first one "where TYPE does not equal storm" and just symbolize this by type like normal, then on the other copy have the definition query "where TYPE equals storm", then symbolize this layer by your other field. 

Bud
by
Esteemed Contributor

Bear in mind that if TYPE is null, it won’t be captured by either of those SQL expressions. But that’s easily fixable if needed:

(TYPE=‘STORM’ OR TYPE IS NULL)
0 Kudos
MErikReedAugusta
Frequent Contributor

Another option is an Arcade script in your symbology.  The code below is mostly pseudocode, so you'll need to adapt it to your actual field names & the type value for 'Storm Water'.

 

if ($feature.typeField == 'Storm Water')
{
  return `${$feature.typeField} ${$feature.secondField}`
}
else
{
  return $feature.typeField
}

 

Also note: If you have a coded domain, the pseudo code above works exclusively with the raw codes, and not the alias.  Below is pseudocode for the alias:

 

if (DomainName($feature, 'typeField') = 'Storm Water')
{
  return `${DomainName($feature, 'typeField')} ${DomainName($feature, 'secondField')}`
}
else
{
  return DomainName($feature, 'typeField')
}

 

As an aside, if you aren't familiar with the backtick notation in Line 3, it's a way of writing your variables directly in-line with your formatting, similar to Python's f-strings.  Variables go in curly braces preceded by a dollar sign: ${variablehere}.  Anything else is treated as part of the string and is displayed as-is, including line breaks.

If your typeField is "Storm Water" and your secondField is "Foobar" then the result returned by line 3 would be "Storm Water Foobar"

0 Kudos
MErikReedAugusta
Frequent Contributor

Also, a caveat to this approach: If you have a possible label class that doesn't exist in your underlying data, it won't show up in the legend.  For example, if "Storm Water Foobar" is a valid result, but none of your features have the combination of "Storm Water" and "Foobar", then it doesn't get generated.

And unfortunately, manually adding results to the list like you would for a non-Arcade symbology isn't currently possible, though there's an Idea about it here that you may want to consider upvoting: https://community.esri.com/t5/arcgis-pro-ideas/add-unlisted-values-in-arcade-driven-symbology/idi-p/...

The current workaround for these cases is to create a temporary feature that does have that combination, then refresh your symbology, and then cancel the edit session with the temporary feature.

0 Kudos
MikhaylaB
Frequent Contributor

Thanks for the detailed explanation; I think this is how I'm going to handle it. It is a coded domain, so I'm going to tweak your second example for my data.

0 Kudos
Bud
by
Esteemed Contributor

What kind of geodatabase? I.e., Oracle enterprise geodatabase?

You could use a database view or a query layer to combine the two fields into a SQL calculated field. Then symbolize on that calculated field.

https://www.w3schools.com/sql/sql_case.asp 

0 Kudos