Hi Joe Head , to start with the support of Arcade in Operations Dashboard, if you look at this help topic: What's new?—Operations Dashboard for ArcGIS | ArcGIS you will see:
Use better maps, with support for smart mapping, heat map renderers, vector basemaps, stream layers, and labels. You can also use Arcade expressions to enhance map labels and symbology, as well as create custom pop-up content.
... and in this topic: Operation views—Operations Dashboard for ArcGIS | ArcGIS it states:
More of the modern capabilities of the ArcGIS platform are supported in dashboards. This includes labels, smart mapping, vector basemaps, stream layers, heat map renderers, and Arcade expressions.
So, Arcade expressions are supported in the Operations Dashboard. I will dig in a little further if these virtual fields created with Arcade expressions are available to use in the widgets.
As for your use case, I understand what you are after. Have a look at the Arcade snippet below:
var elements = Round(Random() * 3 + 2.5, 0);
Console("elements:" + elements);
var dct_status_cost = {};
for (var i = 0; i < elements; i++) {
Console("i:" + i);
var cost = Random() * 100.0 + 50.0;
Console("cost:" + cost);
var status = Round(Random() * 3 + 0.5, 0);
Console("status:" + status);
var key = Text(i);
Console("key:" + key);
dct_status_cost[key] = [status, cost];
}
var total_cost = 0;
for (var i = 0; i < elements; i++) {
Console("i:" + i);
key = Text(i);
var data = dct_status_cost[key];
status = data[0];
Console("status:" + status);
cost = data[1];
Console("cost:" + cost);
var cost_factor = status / 10.0 + 0.1;
Console("cost_factor:" + cost_factor);
Console("cost_factor * cost:" + cost_factor * cost);
total_cost += cost_factor * cost;
Console("total_cost:" + total_cost);
}
return total_cost;
The first part is to mimic the part of getting values from multiple features (which is not possible yet in Arcade). The second part calculated the sum of the cost including the influence of the status on the value.
The Console statements write text to the console. Here is what is written to the console:
elements:4
i:0
cost:131.6079845894106
status:1
key:0
i:1
cost:103.36961796067972
status:3
key:1
i:2
cost:111.06575191076075
status:3
key:2
i:3
cost:127.81189378433866
status:3
key:3
i:0
status:1
cost:131.6079845894106
cost_factor:0.2
cost_factor * cost:26.32159691788212
total_cost:26.32159691788212
i:1
status:3
cost:103.36961796067972
cost_factor:0.4
cost_factor * cost:41.34784718427189
total_cost:67.66944410215402
i:2
status:3
cost:111.06575191076075
cost_factor:0.4
cost_factor * cost:44.4263007643043
total_cost:112.09574486645832
i:3
status:3
cost:127.81189378433866
cost_factor:0.4
cost_factor * cost:51.12475751373547
total_cost:163.22050238019378
In the case described by Cesar only those features with a specific ID will need to be retrieved to define the output value of the expression. This is a single request and is something that could be done. In your case for each value possibly a full table scan is required which would be killing on performance.