1908
11
01-26-2021 02:47 PM
New Contributor III

Hi

I have data collected in the field as

Depth rim to invert (A)

Depth Rim to Debris (B)

Depth Rim to Bottom (C)

I need Arcade expression for display as

If (C-B)>(C-A)/3              ‘Need Cleaning’

Else                                          ‘No Cleaning Needed’

Here is my expression

The expression Test passed but doesn’t reflect the counts in the layers as there is one data that supposed to return “Cleaning Needed”. This is reflected as 'Other' with 0 counts.

Not sure what I am missing

1 Solution

Accepted Solutions
Esri Esteemed Contributor

Hi @KhemAryal ,

If I look at your expression and the explanation it seems that you inverted debris and invert in the conditional statement.

``````var A = 2.50; // rim to Invert (A)
var B = 1.60; // rim to Debris (B)
var C = 3.50; // rim to Bottom (C)

var debris = C-A; // rim to Bottom (C) - rim to Debris (A)
var invert = C-B; // rim to Bottom (C) - rim to Invert (B)
Console("debris: " + debris);
Console("invert: " + invert);

// If (C-B)>(C-A)/3  'Need Cleaning'
// Else             'No Cleaning Needed'

Console("debris/3: " + debris/3);

if (invert>debris/3) {
return 'Need Cleaning';
} else {
return 'No Cleaning Needed';
}``````

This returns "Need Cleaning" and it writes the following to the console:

``````debris: 1
invert: 1.9
debris/3: 0.3333333333333333``````

11 Replies
MVP Frequent Contributor

It looks fine to me, but the logical test is obviously failing on everything and the Else is being returned.

Perhaps it's a text field rather than a float/number?  Only other suggestion is to try returning debris, invert and your logical test to debug.

New Contributor III

Thanks @DavidPike

The field type is not text but 'Double'

Wondering how do you debug the logical test?

MVP Frequent Contributor

just label everything as debris, then invert/3 and see whats happening possibly.  maybe needs to be invert/3.0 if arcade is funny that way?

Esri Esteemed Contributor

Hi @KhemAryal ,

If I look at your expression and the explanation it seems that you inverted debris and invert in the conditional statement.

``````var A = 2.50; // rim to Invert (A)
var B = 1.60; // rim to Debris (B)
var C = 3.50; // rim to Bottom (C)

var debris = C-A; // rim to Bottom (C) - rim to Debris (A)
var invert = C-B; // rim to Bottom (C) - rim to Invert (B)
Console("debris: " + debris);
Console("invert: " + invert);

// If (C-B)>(C-A)/3  'Need Cleaning'
// Else             'No Cleaning Needed'

Console("debris/3: " + debris/3);

if (invert>debris/3) {
return 'Need Cleaning';
} else {
return 'No Cleaning Needed';
}``````

This returns "Need Cleaning" and it writes the following to the console:

``````debris: 1
invert: 1.9
debris/3: 0.3333333333333333``````

New Contributor III

Hey XanderBakker

That expression now solved my problem.

You are a GEM and a great resource for us in this forum.

Esri Esteemed Contributor

You're welcome @KhemAryal . I'm glad it works.

New Contributor III

I did not notice this yesterday but Its showing different than expected on the count. there are actually total of 3187 features (not 1000). and there should be 2 counts 'need cleaning', What do you think?

Esri Esteemed Contributor

Hi @KhemAryal ,

The symbology is probably limited to reading 1000 features for performance reasons. Do you need the correct statistics for the entire layer?

New Contributor III

Yes I need to reflect all the features in the layer with the symbology. Otherwise I have to create more fields and individually insert domains - cleaning needed or not needed