<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Data Expression to Reshape Attribute Table Removes Ability to Filter Map in ArcGIS Dashboards Questions</title>
    <link>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-to-reshape-attribute-table-removes/m-p/1153142#M5970</link>
    <description>&lt;H1&gt;Background&lt;/H1&gt;&lt;P&gt;I have a feature service in this format:&lt;/P&gt;&lt;TABLE border="1" width="63.99923487628602%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="20%"&gt;Trail_Name&lt;/TD&gt;&lt;TD width="20%"&gt;Group1_Inspection&lt;/TD&gt;&lt;TD width="20%"&gt;Group2_Inspection&lt;/TD&gt;&lt;TD width="20%"&gt;Group3_Inspection&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="20%"&gt;Trail 1&lt;/TD&gt;&lt;TD width="20%"&gt;Not Inspected&lt;/TD&gt;&lt;TD width="20%"&gt;Inspected&lt;/TD&gt;&lt;TD width="20%"&gt;Inspected&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="20%"&gt;Trail 2&lt;/TD&gt;&lt;TD width="20%"&gt;Inspected&lt;/TD&gt;&lt;TD width="20%"&gt;Inspected&lt;/TD&gt;&lt;TD width="20%"&gt;Inspected&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I needed to re-arrange the data for graphing in a dashboard, so I figured out how to use a Data Expression to reshape the attribute table into this format:&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%"&gt;Trail_Name&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;Inspection_Group&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;Inspection_Status&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%"&gt;Trail 1&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;Group1&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;Not Inspected&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%"&gt;Trail 2&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;Group1&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;Inspected&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Trail 1&lt;/TD&gt;&lt;TD&gt;Group2&lt;/TD&gt;&lt;TD&gt;Inspected&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;And so on...&lt;/P&gt;&lt;P&gt;Essentially, this way I could graph by Inspection Group and split the data in the graph by Inspection Status so I could display in the dashboard how many groups have completed their various inspections.&amp;nbsp; Assuming&amp;nbsp;the method to the madness matters, you can see essentially how I did this in the code snippet at the end of the post.&amp;nbsp; The code works, and I'm able to create a graph the way I wanted.&amp;nbsp; &lt;STRONG&gt;However...&lt;/STRONG&gt;&lt;/P&gt;&lt;H1&gt;Question&lt;/H1&gt;&lt;P&gt;The issue I'm having is that my graph does not allow me the option to filter my map, based on column selection.&amp;nbsp; When I try to configure the chart properties for filtering, it wants me to specify destination and target fields.&amp;nbsp; Well, I retained trail name in an attempt to make this work, but it doesn't allow that as an option.&amp;nbsp; So, I'm trying to figure out whether that was due to the way I split up my data through my data expression - or alternatively if it's just not possible after the data re-arrange.&amp;nbsp; Anybody have any clues?&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;H1&gt;Code Appendix&lt;/H1&gt;&lt;LI-CODE lang="python"&gt;var portal = Portal('https://www.arcgis.com/');
var fs = FeatureSetByPortalItem(
    portal,
    '1234567890',
    0,
    [
        'TRLNAME',
        'Group1_Inspection',
        'Group2_Inspection',
        'Group3_Inspection'
    ],
    false
);

var g1 = GroupBy(fs, ['Group1_Inspection', 'TRLNAME'], [{name: 'Count', expression: "1", statistic: 'COUNT'}])
var g2 = GroupBy(fs, ['Group2_Inspection', 'TRLNAME'], [{name: 'Count', expression: "1", statistic: 'COUNT'}])
var g3 = GroupBy(fs, ['Group3_Inspection', 'TRLNAME'], [{name: 'Count', expression: "1", statistic: 'COUNT'}])

var features = [];
var feat;

for (var g in g1) {
    feat = {
        attributes: {
            TRLNAME: g['TRLNAME'],
            inspection_group: 'Group1',
            inspection_status: g['Group1_Inspection'],
            Combined_Segment_count: g['Count']
        }
    };
    Push(features,feat);
}

for (var g in g2) {
    feat = {
        attributes: {
            TRLNAME: g['TRLNAME'],
            inspection_group: 'Group2',
            inspection_status: g['Group2_Inspection'],
            Combined_Segment_count: g['Count']
        }
    };
    Push(features,feat);
}

for (var g in g3) {
    feat = {
        attributes: {
            TRLNAME: g['TRLNAME'],
            inspection_group: 'Group3',
            inspection_status: g['Group3_Inspection'],
            Combined_Segment_count: g['Count']
        }
    };
    Push(features,feat);
}

var fsDict = {
    'fields': [
        {'name':'TRLNAME', 'type':'esriFieldTypeString'},
        {'name':'Inspection_Group', 'type':'esriFieldTypeString'},
        {'name':'Inspection_Status', 'type':'esriFieldTypeString'},
        {'name':'Combined_Segment_Count', 'type':'esriFieldTypeInteger'}
    ],
    'geometryType': '',
    'features': features,
}

return FeatureSet(Text(fsDict));&lt;/LI-CODE&gt;</description>
    <pubDate>Sat, 12 Mar 2022 00:17:10 GMT</pubDate>
    <dc:creator>JoshuaFlickinger</dc:creator>
    <dc:date>2022-03-12T00:17:10Z</dc:date>
    <item>
      <title>Data Expression to Reshape Attribute Table Removes Ability to Filter Map</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-to-reshape-attribute-table-removes/m-p/1153142#M5970</link>
      <description>&lt;H1&gt;Background&lt;/H1&gt;&lt;P&gt;I have a feature service in this format:&lt;/P&gt;&lt;TABLE border="1" width="63.99923487628602%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="20%"&gt;Trail_Name&lt;/TD&gt;&lt;TD width="20%"&gt;Group1_Inspection&lt;/TD&gt;&lt;TD width="20%"&gt;Group2_Inspection&lt;/TD&gt;&lt;TD width="20%"&gt;Group3_Inspection&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="20%"&gt;Trail 1&lt;/TD&gt;&lt;TD width="20%"&gt;Not Inspected&lt;/TD&gt;&lt;TD width="20%"&gt;Inspected&lt;/TD&gt;&lt;TD width="20%"&gt;Inspected&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="20%"&gt;Trail 2&lt;/TD&gt;&lt;TD width="20%"&gt;Inspected&lt;/TD&gt;&lt;TD width="20%"&gt;Inspected&lt;/TD&gt;&lt;TD width="20%"&gt;Inspected&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I needed to re-arrange the data for graphing in a dashboard, so I figured out how to use a Data Expression to reshape the attribute table into this format:&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%"&gt;Trail_Name&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;Inspection_Group&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;Inspection_Status&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%"&gt;Trail 1&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;Group1&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;Not Inspected&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%"&gt;Trail 2&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;Group1&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;Inspected&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Trail 1&lt;/TD&gt;&lt;TD&gt;Group2&lt;/TD&gt;&lt;TD&gt;Inspected&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;And so on...&lt;/P&gt;&lt;P&gt;Essentially, this way I could graph by Inspection Group and split the data in the graph by Inspection Status so I could display in the dashboard how many groups have completed their various inspections.&amp;nbsp; Assuming&amp;nbsp;the method to the madness matters, you can see essentially how I did this in the code snippet at the end of the post.&amp;nbsp; The code works, and I'm able to create a graph the way I wanted.&amp;nbsp; &lt;STRONG&gt;However...&lt;/STRONG&gt;&lt;/P&gt;&lt;H1&gt;Question&lt;/H1&gt;&lt;P&gt;The issue I'm having is that my graph does not allow me the option to filter my map, based on column selection.&amp;nbsp; When I try to configure the chart properties for filtering, it wants me to specify destination and target fields.&amp;nbsp; Well, I retained trail name in an attempt to make this work, but it doesn't allow that as an option.&amp;nbsp; So, I'm trying to figure out whether that was due to the way I split up my data through my data expression - or alternatively if it's just not possible after the data re-arrange.&amp;nbsp; Anybody have any clues?&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;H1&gt;Code Appendix&lt;/H1&gt;&lt;LI-CODE lang="python"&gt;var portal = Portal('https://www.arcgis.com/');
var fs = FeatureSetByPortalItem(
    portal,
    '1234567890',
    0,
    [
        'TRLNAME',
        'Group1_Inspection',
        'Group2_Inspection',
        'Group3_Inspection'
    ],
    false
);

var g1 = GroupBy(fs, ['Group1_Inspection', 'TRLNAME'], [{name: 'Count', expression: "1", statistic: 'COUNT'}])
var g2 = GroupBy(fs, ['Group2_Inspection', 'TRLNAME'], [{name: 'Count', expression: "1", statistic: 'COUNT'}])
var g3 = GroupBy(fs, ['Group3_Inspection', 'TRLNAME'], [{name: 'Count', expression: "1", statistic: 'COUNT'}])

var features = [];
var feat;

for (var g in g1) {
    feat = {
        attributes: {
            TRLNAME: g['TRLNAME'],
            inspection_group: 'Group1',
            inspection_status: g['Group1_Inspection'],
            Combined_Segment_count: g['Count']
        }
    };
    Push(features,feat);
}

for (var g in g2) {
    feat = {
        attributes: {
            TRLNAME: g['TRLNAME'],
            inspection_group: 'Group2',
            inspection_status: g['Group2_Inspection'],
            Combined_Segment_count: g['Count']
        }
    };
    Push(features,feat);
}

for (var g in g3) {
    feat = {
        attributes: {
            TRLNAME: g['TRLNAME'],
            inspection_group: 'Group3',
            inspection_status: g['Group3_Inspection'],
            Combined_Segment_count: g['Count']
        }
    };
    Push(features,feat);
}

var fsDict = {
    'fields': [
        {'name':'TRLNAME', 'type':'esriFieldTypeString'},
        {'name':'Inspection_Group', 'type':'esriFieldTypeString'},
        {'name':'Inspection_Status', 'type':'esriFieldTypeString'},
        {'name':'Combined_Segment_Count', 'type':'esriFieldTypeInteger'}
    ],
    'geometryType': '',
    'features': features,
}

return FeatureSet(Text(fsDict));&lt;/LI-CODE&gt;</description>
      <pubDate>Sat, 12 Mar 2022 00:17:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-to-reshape-attribute-table-removes/m-p/1153142#M5970</guid>
      <dc:creator>JoshuaFlickinger</dc:creator>
      <dc:date>2022-03-12T00:17:10Z</dc:date>
    </item>
    <item>
      <title>Re: Data Expression to Reshape Attribute Table Removes Ability to Filter Map</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-to-reshape-attribute-table-removes/m-p/1153170#M5971</link>
      <description>&lt;P&gt;I can't see a reason why this would happen. I have data expression layers filtering map layers in exactly the way you are attempting to do yourself.&lt;/P&gt;&lt;P&gt;Is it, by chance, a Map Image layer, as opposed to a Feature Layer?&lt;/P&gt;&lt;P&gt;When you attempt to add the action between the chart and the map, what, if anything, do you see?&lt;/P&gt;</description>
      <pubDate>Sat, 12 Mar 2022 14:14:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-to-reshape-attribute-table-removes/m-p/1153170#M5971</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2022-03-12T14:14:45Z</dc:date>
    </item>
    <item>
      <title>Re: Data Expression to Reshape Attribute Table Removes Ability to Filter Map</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-to-reshape-attribute-table-removes/m-p/1154333#M5984</link>
      <description>&lt;P&gt;Hi Josh - I actually used some of your other responses here on GeoNet to work out how to re-arrange my data; in case you don't hear it enough, thanks for being a contributor.&amp;nbsp; I'm sure I'm not alone in having learned from your experience/expertise.&lt;/P&gt;&lt;P&gt;I'm talking to a feature layer, not a map image layer, but I did figure out the issue.&amp;nbsp; I was charting off of Inspection Group and Inspection Status.&amp;nbsp; I thought Trail Name could still be used as a filter, but I overestimated the ability of the Dashboard in that respect.&amp;nbsp; When I charted off of Trail Name, the filter worked.&lt;/P&gt;&lt;P&gt;One additional issue I noticed is that, when attempting to filter the chart based on map extent, the whole chart breaks down.&amp;nbsp; It will just return 'No Data'.&amp;nbsp; To the best of your knowledge, is that just a limitation of the data expressions?&amp;nbsp; I'm guessing it's just too much processing to occur any time the map is adjusted.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Mar 2022 15:48:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-to-reshape-attribute-table-removes/m-p/1154333#M5984</guid>
      <dc:creator>JoshuaFlickinger</dc:creator>
      <dc:date>2022-03-16T15:48:15Z</dc:date>
    </item>
    <item>
      <title>Re: Data Expression to Reshape Attribute Table Removes Ability to Filter Map</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-to-reshape-attribute-table-removes/m-p/1154337#M5985</link>
      <description>&lt;P&gt;Glad you figured it out!&lt;/P&gt;&lt;P&gt;The key to that second issues is this:&lt;/P&gt;&lt;PRE&gt;geometryType: ''&lt;/PRE&gt;&lt;P&gt;Without including the geometry of your features, there's nothing for the map to act against.&lt;/P&gt;&lt;P&gt;You &lt;EM&gt;can &lt;/EM&gt;include the geometry in your output, but your expression will suffer decreased performance. Since you're grouping, you'd need to somehow perform a Union somewhere in your expression, and that kind of thing can get pretty "expensive" in terms of compute time.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Mar 2022 15:55:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-to-reshape-attribute-table-removes/m-p/1154337#M5985</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2022-03-16T15:55:19Z</dc:date>
    </item>
  </channel>
</rss>

