Select to view content in your preferred language

Need help connecting two layers with slightly differently labeled state abreviations.

343
7
Jump to solution
a month ago
JHolbrook
New Contributor III

Hello,

I'm having trouble getting a dashboard with a dropdown state selector to filter a wildfire label.

 

The dropdown uses standard state abbreviations (AZ/AK/AR, etc) while the wildfire layer has for some reason decided to name them US-AZ/US-AK/US-AR.

 

I'd previously found a way to cut the "US-" off of the abbreviations when labeling them, or creating an expression within the map, but I see no way to reference the map's expressions while inside the dashboard.

 

Can anyone point me in the right direction?

 

Thank you.

 

 

0 Kudos
1 Solution

Accepted Solutions
jcarlson
MVP Esteemed Contributor

Oh, that's no good. If you need your selector to act against multiple data sources that have conflicting values, it gets messier, maybe impossible. But I think we can still do this.

Here's an idea: set the selector to Features, not Grouped Values. Since we have one entry per state, it's fine. On the Features setting, your filter actions can use different fields.

If we amend that expression to include things like the state's proper name, abbreviations, etc., we can filter different widgets on their appropriate fields.

return FeatureSet(Text({
    fields: [
        {
            name: 'territory_state',
            alias: 'Point of Origin State',
            type: 'esriFieldTypeString',
            domain: {
                name: 'state-abbrev-domain',
                type: 'codedValue',
                codedValues: [
                    {code:"US-AL", name: "AL"},
                    {code:"US-AK", name: "AK"},
                    // etc
                ]
            }
        },
        { name: 'state_abbrev', type: 'esriFieldTypeString' },
        { name: 'state_full', type: 'esriFieldTypeString' }
    ],
    features: [
        {attributes: {territory_state: "US-AL", state_abbrev: 'AL', state_full: 'Alabama'}},
        {attributes: {territory_state: "US-AK", state_abbrev: 'AK', state_full: 'Alaska'}},
        // etc
    ],
    geometryType: ''
}))

jcarlson_0-1719601794756.png

The end result is a selector that can behave differently to accommodate the layer it's interacting with. What do you think, will it work?

- Josh Carlson
Kendall County GIS

View solution in original post

7 Replies
jcarlson
MVP Esteemed Contributor

So is the issue just that you don't want the "US-" part in the dropdown? You can do it with a data expression!

It's kind of goofy, but trust me, it works. By creating a field with a domain, we can tell it to associate the 2-letter abbreviation with the US-**unspecified** format.

return FeatureSet(Text({
    fields: [
        {
            name: 'state',
            alias: 'Point of Origin State',
            type: 'esriFieldTypeString',
            domain: {
                name: 'state-abbrev-domain',
                type: 'codedValue',
                codedValues: [
                    {code:"US-AL", name: "AL"},
                    {code:"US-AK", name: "AK"},
                    {code:"US-AZ", name: "AZ"},
                    {code:"US-AR", name: "AR"},
                    {code:"US-CA", name: "CA"},
                    {code:"US-CO", name: "CO"},
                    {code:"US-CT", name: "CT"},
                    {code:"US-DE", name: "DE"},
                    {code:"US-FL", name: "FL"},
                    {code:"US-GA", name: "GA"},
                    {code:"US-HI", name: "HI"},
                    {code:"US-ID", name: "ID"},
                    {code:"US-IL", name: "IL"},
                    {code:"US-IN", name: "IN"},
                    {code:"US-IA", name: "IA"},
                    {code:"US-KS", name: "KS"},
                    {code:"US-KY", name: "KY"},
                    {code:"US-LA", name: "LA"},
                    {code:"US-ME", name: "ME"},
                    {code:"US-MD", name: "MD"},
                    {code:"US-MA", name: "MA"},
                    {code:"US-MI", name: "MI"},
                    {code:"US-MN", name: "MN"},
                    {code:"US-MS", name: "MS"},
                    {code:"US-MO", name: "MO"},
                    {code:"US-MT", name: "MT"},
                    {code:"US-NE", name: "NE"},
                    {code:"US-NV", name: "NV"},
                    {code:"US-NH", name: "NH"},
                    {code:"US-NJ", name: "NJ"},
                    {code:"US-NM", name: "NM"},
                    {code:"US-NY", name: "NY"},
                    {code:"US-NC", name: "NC"},
                    {code:"US-ND", name: "ND"},
                    {code:"US-OH", name: "OH"},
                    {code:"US-OK", name: "OK"},
                    {code:"US-OR", name: "OR"},
                    {code:"US-PA", name: "PA"},
                    {code:"US-RI", name: "RI"},
                    {code:"US-SC", name: "SC"},
                    {code:"US-SD", name: "SD"},
                    {code:"US-TN", name: "TN"},
                    {code:"US-TX", name: "TX"},
                    {code:"US-UT", name: "UT"},
                    {code:"US-VT", name: "VT"},
                    {code:"US-VA", name: "VA"},
                    {code:"US-WA", name: "WA"},
                    {code:"US-WV", name: "WV"},
                    {code:"US-WI", name: "WI"},
                    {code:"US-WY", name: "WY"}
                ]
            }
        }
    ],
    features: [
        {attributes: {state: "US-AL"}},
        {attributes: {state: "US-AK"}},
        {attributes: {state: "US-AZ"}},
        {attributes: {state: "US-AR"}},
        {attributes: {state: "US-CA"}},
        {attributes: {state: "US-CO"}},
        {attributes: {state: "US-CT"}},
        {attributes: {state: "US-DE"}},
        {attributes: {state: "US-FL"}},
        {attributes: {state: "US-GA"}},
        {attributes: {state: "US-HI"}},
        {attributes: {state: "US-ID"}},
        {attributes: {state: "US-IL"}},
        {attributes: {state: "US-IN"}},
        {attributes: {state: "US-IA"}},
        {attributes: {state: "US-KS"}},
        {attributes: {state: "US-KY"}},
        {attributes: {state: "US-LA"}},
        {attributes: {state: "US-ME"}},
        {attributes: {state: "US-MD"}},
        {attributes: {state: "US-MA"}},
        {attributes: {state: "US-MI"}},
        {attributes: {state: "US-MN"}},
        {attributes: {state: "US-MS"}},
        {attributes: {state: "US-MO"}},
        {attributes: {state: "US-MT"}},
        {attributes: {state: "US-NE"}},
        {attributes: {state: "US-NV"}},
        {attributes: {state: "US-NH"}},
        {attributes: {state: "US-NJ"}},
        {attributes: {state: "US-NM"}},
        {attributes: {state: "US-NY"}},
        {attributes: {state: "US-NC"}},
        {attributes: {state: "US-ND"}},
        {attributes: {state: "US-OH"}},
        {attributes: {state: "US-OK"}},
        {attributes: {state: "US-OR"}},
        {attributes: {state: "US-PA"}},
        {attributes: {state: "US-RI"}},
        {attributes: {state: "US-SC"}},
        {attributes: {state: "US-SD"}},
        {attributes: {state: "US-TN"}},
        {attributes: {state: "US-TX"}},
        {attributes: {state: "US-UT"}},
        {attributes: {state: "US-VT"}},
        {attributes: {state: "US-VA"}},
        {attributes: {state: "US-WA"}},
        {attributes: {state: "US-WV"}},
        {attributes: {state: "US-WI"}},
        {attributes: {state: "US-WY"}}
    ],
    geometryType: ''
}))

 Then set your selector to Grouped Features with that as your Data Expression. The selector shows the name, but it acts on the code. I included the US-**unspecified** code on my list to show.

jcarlson_0-1719593975140.png

jcarlson_1-1719594006707.png

 

- Josh Carlson
Kendall County GIS
JHolbrook
New Contributor III

Josh,

 

So the drop down is state and US territory info, which includes the proper names, as well as 2 letter abbreviations.  That drop down filters to a bunch of different elements across the board, not just the wildfires list.  

 

Everything else works from the drop down, but the weird abbreviation pattern in the wildfire layer is the problem.  The wildfire layer appears on the map, and is the data referenced in the list.  I don't want to change the drop down to be the data from the wildfire layer because it would then be restricted to states and not territories/DC.  Also, my other boards, use the same data sets for the drop downs for consistency purposes.

 

I appreciate the help!

0 Kudos
jcarlson
MVP Esteemed Contributor

Oh, that's no good. If you need your selector to act against multiple data sources that have conflicting values, it gets messier, maybe impossible. But I think we can still do this.

Here's an idea: set the selector to Features, not Grouped Values. Since we have one entry per state, it's fine. On the Features setting, your filter actions can use different fields.

If we amend that expression to include things like the state's proper name, abbreviations, etc., we can filter different widgets on their appropriate fields.

return FeatureSet(Text({
    fields: [
        {
            name: 'territory_state',
            alias: 'Point of Origin State',
            type: 'esriFieldTypeString',
            domain: {
                name: 'state-abbrev-domain',
                type: 'codedValue',
                codedValues: [
                    {code:"US-AL", name: "AL"},
                    {code:"US-AK", name: "AK"},
                    // etc
                ]
            }
        },
        { name: 'state_abbrev', type: 'esriFieldTypeString' },
        { name: 'state_full', type: 'esriFieldTypeString' }
    ],
    features: [
        {attributes: {territory_state: "US-AL", state_abbrev: 'AL', state_full: 'Alabama'}},
        {attributes: {territory_state: "US-AK", state_abbrev: 'AK', state_full: 'Alaska'}},
        // etc
    ],
    geometryType: ''
}))

jcarlson_0-1719601794756.png

The end result is a selector that can behave differently to accommodate the layer it's interacting with. What do you think, will it work?

- Josh Carlson
Kendall County GIS
JHolbrook
New Contributor III

Josh,  I think this will work.  I can't be sure though since apparently many of my connected Esri Livefeeds layers all just broke and I won't be to try to do this until they are back up and running.  Thanks again, Josh!

0 Kudos
jcarlson
MVP Esteemed Contributor

Happy to help! This was an interesting one, and something that I might use in some of my own dashboards!

- Josh Carlson
Kendall County GIS
jcarlson
MVP Esteemed Contributor

Oh, you know what? If you do the Features selector with the different values, you could actually drop that entire domain section of the expression. That will keep things a bit more concise.

- Josh Carlson
Kendall County GIS
JHolbrook
New Contributor III

Thanks again, Josh!

0 Kudos