Hi!
I am having a hard time figuring out arcade expression to work within my dashboard. I also don't fully know if it is even possible to do within dashboards. Anyway....
I have a dashboard that is connect to a Survey123. The survey contains a multiple select question, which I learned is saved as csv, so I found an expression to split out the answers from the multiple select question. The issue is I now need to connect this new feature set dictionary to the existing feature layer within the webmap. So, I created a join expression, but I keep getting and can't figure out how to correct:
Expected "'", "(", "+", "-", "@", "CASE", "DATE", "EXTRACT", "FALSE", "INTERVAL", "N'", "NULL", "POSITION", "SUBSTRING", "TIMESTAMP", "TRIM", "TRUE", "`", [ \t\n\r], [0-9], or [A-Za-z_\x80-] but "$" found.
The end goal is that someone can search by specific rent amount and see what locations offer that rent amount.
Dashboard below
https://dgco.maps.arcgis.com/apps/dashboards/2df513c195bb4560b61145f4064484dd
Expression below
// Reference layer using the FeatureSetByPortalItem() function.
var fs = FeatureSetByPortalItem(Portal('https://www.arcgis.com'), '288db7f54ea048c5b6241f156ef0f646' , 0, ['*'], true);
// Empty dictionary to capture each rental amount reported as separate rows.
var choicesDict = {'fields': [{ 'name': 'split_choices', 'type': 'esriFieldTypeString'}],
'geometryType': 'esriGeometryPoint', 'features': []};
var index = 0;
// Split comma separated Rental Amountss and store in dictionary.
for (var feature in fs) {
var split_array = Split(feature["rent_amount"], ',')
var count_arr = Count(split_array)
for(var i = 0; i < count_arr; i++ ){
choicesDict.features[index++] = {
'attributes': { 'split_choices': Trim(split_array[i]),
}}
}}
// Convert dictionary to featureSet.
var fs_dict = FeatureSet(Text(choicesDict));
GroupBy(fs_dict, ['split_choices'],
[{ name: 'split_count', expression: 'split_choices', statistic: 'COUNT' }]);
var joinedDict = {
fields: [
{ name: "split_choices", type: "esriFieldTypeString" },
{ name: "address", type: "esriFieldTypeString" },
{ name: "landlord", type: "esriFieldTypeString" },
],
geometryType: "esriGeometryPoint",
'features':[]};
var i = 0;
for (var t in fs_dict) {
var fsid = t["split_choices"]
for (var p in Filter(fs, "SplitChoices = "+fsID)){
joinedDict.features[i] = {
attributes: {
SplitChoices: fsID,
Address: p["address"],
Landlord: t["landlord"],
},
geometry: Geometry(p)
}
}
i++
}
return FeatureSet(Text(joinedDict));
If there is better way for handling this issue, let me know!
Thanks
Scout