Select to view content in your preferred language

Arcade expression not behaving as expected in dashboard

109
0
12-12-2024 01:07 PM
Ulises
by
Frequent Contributor

We used Workflow Manager and have 2 workflow items with the same data and properties but different timeframes. I'm not a programmer but managed to create an arcade expression that combines information from both wmx items to consolidate data in a dashboard. The problem is that although the fields used in the arcade expression are the same as using just the table from 1 item, it behave different.

I used a sublayer from a hosted view in WMX to access extended properties fields. Our serial chart considered just distinct values when setting that parameter in the dashboard.

 Screenshot 2024-12-12 170121.png

 

When using the arcade expression and the data combined from the same fields the chart shows equal amount of values when the distinct setting is configured.

Screenshot 2024-12-12 170230.png

 

Not setting the distinct parameter shows the correct pattern distribution but considering all records instead of just distinct values.

Why the dashboard do not show the same for both data options? What modification to the expression needs to be made to ensure the expected behavior as with accessing only 1 sublayer?

The expression is...

var portal = Portal('https://myPortal/portal');

var db1 = FeatureSetByPortalItem(portal, 'id_from_first_workflow', 8, ["job_id","job_name","created_date","job_status","closed","has_location","assigned_to","priority","end_date","extProp1_region","extProp2_adm_cierre","extProp2_adm_user"], false)

var db2 = FeatureSetByPortalItem(portal, 'id_from_second_workflow', 8, ["job_id","job_name","created_date","job_status","closed","has_location","assigned_to","priority","end_date","extProp1_region","extProp2_adm_cierre","extProp2_adm_user"], false)

var today_date = Today();

var features = [];
var feat;


for (var f1 in db1) {
feat = {
attributes: {
flujo: '1',
jobid: f1['job_id'],
jobname: f1['job_name'],
jobstatus: f1['job_status'],
closed: f1['closed'],
assigned_to: f1['assigned_to'],
priority: f1['priority'],
region: f1['extProp1_region'],
adm_cierre: f1['extProp2_adm_cierre'],
adm_user: f1['extProp2_adm_user'],
date_start: Number(f1['created_date']),
haslocation: f1['has_location'],
date_end: Number(f1['end_date']),
openDuration: abs(round(DateDiff(today_date,f1['created_date'],'days'),0)),
closeDuration: abs(round(DateDiff(f1['end_date'],f1['created_date'],'days'),0))
},
};
Push(features, feat);
}

for (var f2 in db2) {
feat = {
attributes: {
flujo: '2',
jobid: f2['job_id'],
jobname: f2['job_name'],
jobstatus: f2['job_status'],
closed: f2['closed'],
assigned_to: f2['assigned_to'],
priority: f2['priority'],
region: f2['extProp1_region'],
adm_cierre: f2['extProp2_adm_cierre'],
adm_user: f2['extProp2_adm_user'],
date_start: Number(f2['created_date']),
haslocation: f2['has_location'],
date_end: Number(f2['end_date']),
openDuration: abs(round(DateDiff(today_date,f2['created_date'],'days'),0)),
closeDuration: abs(round(DateDiff(f2['end_date'],f2['created_date'],'days'),0))
},
};
Push(features, feat);
}


var combinedDict = {
fields: [
{name: 'flujo', type: 'esriFieldTypeString' },
{name: 'jobid', type: 'esriFieldTypeString'},
{name: 'jobname', type: 'esriFieldTypeString'},
{name: 'jobstatus', type: 'esriFieldTypeString'},
{name: 'assigned_to', type: 'esriFieldTypeString'},
{name: 'priority', type: 'esriFieldTypeString'},
{name: 'closed', type: 'esriFieldTypeString'},
{name: 'date_start', type: 'esriFieldTypeDate'},
{name: 'haslocation', type: 'esriFieldTypeString'},
{name: 'adm_cierre', type: 'esriFieldTypeString'},
{name: 'adm_user', type: 'esriFieldTypeString'},
{name: 'date_end', type: 'esriFieldTypeDate'},
{name: 'openDuration', type: 'esriFieldTypeDouble'},
{name: 'closeDuration', type: 'esriFieldTypeDouble'},
{name: 'region', type: 'esriFieldTypeString'}
],
geometryType: '',
features: features,
};

return featureset(text(combinedDict));

Any help or suggestions are welcome.

Regards

Ulises Feliciano Troche
0 Kudos
0 Replies