I am trying to sum our plant production from multiple sources.
var portal = Portal("");
var fs = FeatureSetByPortalItem(
portal,
"",
1,
[
"Date_",
"W_F_MGD",
"E_F_MGD",
"TOTAL_W_E_MGD",
"TID_FLOW_MGD",
"REEDER_Percent_FULL",
"TAP_FLOW_MGD",
"PLANT_PRODUCTION_MGD"
],
false
);
// Find the most recent date from the date field to filter the FeatureSet for the latest record
var TotalProduction = Round(Sum(fs, "PLANT_PRODUCTION_MGD")+Sum(fs, "TAP_FLOW_MGD"));
return TotalProduction;
I want to sum the TAP, TID, and Plant production fields. I am getting errors even with the code above. What am I doing wrong.
Update:
using this I was able to sum in the script
Test shows a result but I cannot select it
Solved! Go to Solution.
I'm guessing this is a data expression? The issue is that you have to return a featureSet. I would just construct a simple feature set with the value you need as a single row.
https://doc.arcgis.com/en/dashboards/get-started/create-data-expressions.htm
https://doc.arcgis.com/en/dashboards/reference/authoring-data-expressions.htm
var newDict = {
'fields': [{ 'name': 'totProd', 'type': 'esriFieldTypeDouble'}],
'geometryType': '',
'features': [{
'attributes': {
'totProd': TotalProduction,
}}]
};
return FeatureSet(Text(newDict));
I'm guessing this is a data expression? The issue is that you have to return a featureSet. I would just construct a simple feature set with the value you need as a single row.
https://doc.arcgis.com/en/dashboards/get-started/create-data-expressions.htm
https://doc.arcgis.com/en/dashboards/reference/authoring-data-expressions.htm
var newDict = {
'fields': [{ 'name': 'totProd', 'type': 'esriFieldTypeDouble'}],
'geometryType': '',
'features': [{
'attributes': {
'totProd': TotalProduction,
}}]
};
return FeatureSet(Text(newDict));
Hello,
I’m trying to write an expression in the dashboard to add two layers in a certain field (n_lobitos in both)
I’m not getting it. Any help?
I’ve seen the sample below but it’s different.
https://github.com/Esri/arcade-expressions/blob/master/dashboard_data/CalculationAcrossFields.md
----------------------------------------------------------------------------------