Hello,
I'm using the FeatureSetByRelationshipName to pull related table records into a popup. One of the fields (SumOfReturnMG) being pulled is an integer field and I need to round the number to 2 decimals. What would be be best way to format the field within my existing Arcade expression?
Expression user below
var fs = FeatureSetByRelationshipName($feature,"qry_HUC_USEGROUP_RET" , ['*'], false);
var result = "";
var cnt = Count(fs);
if (cnt > 0) {
// start loop through related records
for (var f in fs) {
// for each f (=feature) in related features, add attendee to the result
result += TextFormatting.NewLine + f.YearNumber + TextFormatting.NewLine + f.SumOfReturnMG;
}
} else {
// overwrite result with text to indicate that there are no attendees
result = "";
}return result;
Resulting record (field highlighted in blue)
Thanks.
You can use the Round() function.
Other stuff:
var fs = FeatureSetByRelationshipName($feature,"qry_HUC_USEGROUP_RET" , ["YearNumber", "SumOfReturnMG"], false);
var result = []; //array
// start loop through related records
for (var f in fs) {
// for each f (=feature) in related features, add attendee to the result
Push(result, f.YearNumber + TextFormatting.NewLine + Round(f.SumOfReturnMG, 2);
}
// if result is empty, return a default value, else return the concatenated array
return IIF(Count(result) == 0, "", Concatenate(result, TextFormatting.NewLine))