I'm having some issues with an arcade expression. I would like to create a feature layer that returns a single value based on the sum of values where if an attribute is populated, it returns 1. There are 3 attributes that need to be scrutinised, thus, for the new feature layer to be presented in the Gauge widget, 100% would equal 3, due to the 3 attributes being populated.
// Reference the FeatureSet by Portal Item
var fs = FeatureSetByPortalItem(
epportal,
'*portal item ID redacted*', // Replace with your portal item ID
0, // Layer index
[
'LoADateSigned',
'HoTsDateSigned',
'GridApplicationSubmissionDate'
],
false
);
// Initialize the count of populated attributes
var populatedCount = 0;
// Get the first feature (assuming you need one feature)
var featuredata = First(fs);
// Check if the feature exists
if (!IsEmpty(featuredata)) {
// Check each attribute: Add 1 if populated
if (!IsEmpty(featuredata.LoADateSigned)) {
populatedCount += 1;
}
if (!IsEmpty(featuredata.HoTsDateSigned)) {
populatedCount += 1;
}
if (!IsEmpty(featuredata.GridApplicationSubmissionDate)) {
populatedCount += 1;
}
}
// Return the total sum of populated attributes
return populatedCount;