I have a series of values in a field that I am trying to calculate the sum and display in an Indicator widget. Within that field, there are duplicate values that I do not want to include in the displayed total. Below is an example:
Currently, the value in my indicator reads 313. However, I want it to read 278 (subtraction of one 35 value).
I think using the Distinct function would allow me to do this, but I am having trouble getting that to work. Would I need to create a Data Expression and call out that new field to sum or can I do this in the Advanced formatting editor itself?
This is what I have started in a new Data Expression:
var fs = FeatureSetByPortalItem(
Portal("https://www.arcgis.com/"),
"384158f2ebe34f8ba8b0b39dfe5f5af5",
0,
['target_goal'],
false
);
var rem_dups = Distinct('target_goal')
return rem_dups
@jcarlson any thoughts on this?
Solved! Go to Solution.
You have the syntax incorrect for the Distinct function. You have to include the FeatureSet. And you should also include the Location field, since you might have two different locations with the same values.
var fs = FeatureSetByPortalItem(
Portal("https://www.arcgis.com/"),
"384158f2ebe34f8ba8b0b39dfe5f5af5",
0,
['Location', 'target_goal'],
false
);
return Distinct(fs, ['Location', 'target_goal'])
You have the syntax incorrect for the Distinct function. You have to include the FeatureSet. And you should also include the Location field, since you might have two different locations with the same values.
var fs = FeatureSetByPortalItem(
Portal("https://www.arcgis.com/"),
"384158f2ebe34f8ba8b0b39dfe5f5af5",
0,
['Location', 'target_goal'],
false
);
return Distinct(fs, ['Location', 'target_goal'])
@KenBuja worked perfectly. Thank you!!
@KenBuja follow-up question to this data expression. If I wanted to return Jurisdictions = All, rather than the 6 total in this dataset. What's the best way to do that?
var fs = FeatureSetByPortalItem(
Portal("https://www.arcgis.com/"),
"384158f2ebe34f8ba8b0b39dfe5f5af5",
0,
['Jurisdiction', 'core_capability', 'target_goal'],
false
);
return Distinct(fs, ['Jurisdiction', 'core_capability', 'target_goal'])
If I understand your question, the Filter function would do that.
that worked, thank you!