Background
I have a feature service in this format:
| Trail_Name | Group1_Inspection | Group2_Inspection | Group3_Inspection |
| Trail 1 | Not Inspected | Inspected | Inspected |
| Trail 2 | Inspected | Inspected | Inspected |
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:
| Trail_Name | Inspection_Group | Inspection_Status |
| Trail 1 | Group1 | Not Inspected |
| Trail 2 | Group1 | Inspected |
| Trail 1 | Group2 | Inspected |
And so on...
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. Assuming the method to the madness matters, you can see essentially how I did this in the code snippet at the end of the post. The code works, and I'm able to create a graph the way I wanted. However...
Question
The issue I'm having is that my graph does not allow me the option to filter my map, based on column selection. When I try to configure the chart properties for filtering, it wants me to specify destination and target fields. Well, I retained trail name in an attempt to make this work, but it doesn't allow that as an option. 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. Anybody have any clues?
Thanks.
Code Appendix
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));