Select to view content in your preferred language

Sum ARCADE with condition

1402
3
04-01-2023 03:22 PM
Labels (1)
AurelienJOSSET
Emerging Contributor

Good morning, I'm looking to make a rather simple ARCADE formula:

the sum of the Shape__Length field with a filter on one field (frequency different from 0 in my case)

Here is where i am now

 

var Sum =Sum($layer, "Shape__Length")

var filter = Filter(Sum, $feature.FREQ_ENTRETIEN !=0)

return filter

 

thanks a lot for your help

Aurelian

3 Replies
JoshuaSharp-Heward
Frequent Contributor

Hi Aurelian,

I think it'd work if you just flipped the first two lines, filtering the $feature.FREQ_ENTRETIEN !=0 values out before you sum them. Just make sure to then put the filter variable into the sum function instead of $layer.

Cheers,

Josh

0 Kudos
Omar_A
by Esri Contributor
Esri Contributor

Hi Aurelien,

The expression you have created is almost correct but needs a small correction to filter the layer before summing the Shape__Length field. 

var filter = Filter($layer, $feature.FREQ_ENTRETIEN != 0);

var Sum = Sum(filter, "Shape__Length");

return Sum;

Best,

Omar

0 Kudos
AurelienJOSSET
Emerging Contributor

Hello to both of you

Thanks for your help.

The solution was ultimately

var filter = Filter($layer, 'FREQ_MAINTENANCE <> 0');

var Sum = Sum(filter, 'Shape__Length');

return Sum;

In the Filter function, the condition must be in SQL.

Again thanks to you

Bye

0 Kudos