I want to create an indicator to count items from multiple layers. Is there any arcade expression example or any reference? Any idea will be appreciated.
Solved! Go to Solution.
@SayedWali- Just to recap and post the solution here, rather than in a private message:
var portal = Portal('https://npaid.maps.arcgis.com');
var FAR = FeatureSetByPortalItem(
portal,
'56db417ebbc541bcbb6ccf9c49524cc9',
0,
['*'],
false
)
var PDIA = FeatureSetByPortalItem(
portal,
'56db417ebbc541bcbb6ccf9c49524cc9',
0,
['*'],
false
)
var total_count = Count(FAR) + Count(PDIA)
var outDict = {
fields: [{ name: 'total', type: 'esriFieldTypeInteger'}],
geometryType: '',
features: [{attributes: {total: total_count}}],
};
// Return dictionary cast as a feature set
return FeatureSet(Text(outDict));
There are a number of examples on ESRI's Arcade expressions GitHub repo. Here's one that counts items from multiple layers for a chart:
If you haven't used a Data Expression before, they can look a lot more complicated than they really are. The linked example should apply just as easily to an Indicator widget.
@SayedWali- Just to recap and post the solution here, rather than in a private message:
var portal = Portal('https://npaid.maps.arcgis.com');
var FAR = FeatureSetByPortalItem(
portal,
'56db417ebbc541bcbb6ccf9c49524cc9',
0,
['*'],
false
)
var PDIA = FeatureSetByPortalItem(
portal,
'56db417ebbc541bcbb6ccf9c49524cc9',
0,
['*'],
false
)
var total_count = Count(FAR) + Count(PDIA)
var outDict = {
fields: [{ name: 'total', type: 'esriFieldTypeInteger'}],
geometryType: '',
features: [{attributes: {total: total_count}}],
};
// Return dictionary cast as a feature set
return FeatureSet(Text(outDict));
Hi @jcarlson , Thank you very much!
@jcarlson , one more question, from the two layers, I want to get a shared field as a long list. For example, I want to have a list of all object IDs from both layers. any idea to edit the expression?