Select to view content in your preferred language

Arcade popup expression to display related attributes but ignore 0 attribute

2911
10
Jump to solution
10-03-2022 02:09 PM
JonathanWhite1
Occasional Contributor

Hello I am trying to display related data in popups using an arcade script I found and altered. The issue is that I need to not return 0  or replace 0 with '' where attribute values are equal to 0. New to Arcade and I have no idea where I would insert a Replace or an if then statement. Right now the following code will show for example 5000 State Highway 149 0 as 0 is listed if the feature doesn't have a StreetType value. I have nulls and blanks calculate automatically to be 0 .  I cant change the database values to be blank or null for a number of reasons which has to do with comparing values..

var related_table = FeatureSetById($datastore, "12");
var filter_query = "Asmt = '" + $feature["APN"] + "'";
var related_data_filtered = Filter(related_table, filter_query);
var related_data_filtered_count = Count(related_data_filtered);

var output = "";
if (related_data_filtered_count > 0) {
output = "Total of " + related_data_filtered_count + " Address(es)";
for (var related_data_row in related_data_filtered) {
output += TextFormatting.NewLine + related_data_row.StreetNum + " " + related_data_row.Street + " " + related_data_row.StreetType + TextFormatting.Newline + "____________";
}
} else {
output = "No Related Records...";

0 Kudos
10 Replies
JonathanWhite1
Occasional Contributor

I tried the above code but it seems to not work or is not supported. Returns nothing in the AGOL popup. Trying to grasp the structure of this code. Never used an array before.

0 Kudos