Select to view content in your preferred language

Counting Features with a specific attribute not working

335
1
Jump to solution
06-16-2022 04:54 AM
Luca_Schikowski
Occasional Contributor

Good morning,

I try to count all adresses (in my Device Layer) with a specific attribute (MainProvider). For that, i tried the following code (as mentioned here: UN Attribute Rules Expression Builder Arcade😞

// load all addresses
var addresses = FeatureSetByName($datastore, "AddressTableName", ["MainProvider"], false)

// filter the addresses for the main provider of the active feature
var provider = $feature.MainProvider
var filtered_addresses = Filter(addresses, "MainProvider = @provider")

// count and return error message
if(Count(filtered_addresses) > 25) {
    return {"errorMessage": "A provider can't supply more than 25 addresses!"}
}

// if we land here, the provider has <= 25 addresses
// rest of your code

When I use this code, the value of "filtered_adresses" is always identical with the amount of features in my device layer. So I guess the Filter is not working like this.

Do you know what I can do here? Or is there another way to get this done? Thanks in advance! 
Luca

0 Kudos
1 Solution

Accepted Solutions
RobertKrisher
Esri Regular Contributor

@Luca_Schikowski  I don't see anything wrong with the code, as its written, but it is dependent on your schema and data. Things I'd be on the look out for:

If the main provided field populated in your source data?

Do they all have the same value?

Is the main provider field on the current feature null? The filter may fail if the current feature has a null provider.

View solution in original post

1 Reply
RobertKrisher
Esri Regular Contributor

@Luca_Schikowski  I don't see anything wrong with the code, as its written, but it is dependent on your schema and data. Things I'd be on the look out for:

If the main provided field populated in your source data?

Do they all have the same value?

Is the main provider field on the current feature null? The filter may fail if the current feature has a null provider.