Skip Null Values Attribute Assistant

907
10
06-09-2020 12:34 PM
KarinaLivingston
Occasional Contributor

Hello, 

I am using the attribute assistant to populate a GIS ID which consists of a location ID - Equipment ID. I have been able to get the assistant to work using the following expression in the Value Info field. ([LOCATIONID]+"-"+[EQUIPMENTID]). This returns GIS IDs but some have a null portion. However, I need a way for the attribute assistant to skip (or not populate) if either the location ID or equipment ID is null. Is there a way to do this? I have tried NOT NULL in a variety of ways but was not successful. 

0 Kudos
10 Replies
JoeBorgione
MVP Emeritus

See if this ( or some variation of it) works for you:  

joinChar = "-"
if IsEmpty($feature.LOCATIONID) || IsEmpty($feature.EQUIPMENTID) {
   continue;
}
else {
   var newID = Concatenate([$feature.LOCATIONID,$feature.EQUIPMENTID],joinChar)
   return newID
}
That should just about do it....
0 Kudos
KarinaLivingston
Occasional Contributor

Thanks for your help, Joe.

This didn't work but I think it's because I have to put it in the "Value Info" field for the Attribute Assistant. All the other examples I have seen are simple. I've been trying combinations of the following expression but keep getting the same results. I know it's similar to the other expression but I feel like this is taking down the right path. 

IIF(IsNull([LOCATIONID]),"",[LOCATIONID] & "-") & IIF(IsNull([EQUIPMENTID]),"",[EQUIPMENTID])

I've been trying to include an OR but it's not working. I want nothing returned if either the LOCATIONID or the EQUIPMENTID have a NULL value. Right now if one or the other has a value it returns the value with a blank for the other value.
EX: I would like the first example to return empty since the second value is null. 

Example

0 Kudos
JoeBorgione
MVP Emeritus

I'm not surprised it didn't work, I'm a hack at best with arcade; the code here is from an attribute rule that was provided to me, and then cobbled together.

What you want seems like it should be possible;  I'll summon the goto guy for arcade:  Xander Bakker‌ I bet you have a suggestion....

That should just about do it....
XanderBakker
Esri Esteemed Contributor

Hi Joe Borgione  and Karina Livingston ,

I guess you could use something like the expression below (this will only return a value when both attributes are not empty):

if (!IsEmpty($feature.LOCATIONID)) {
    if (!IsEmpty($feature.EQUIPMENTID)) {
        return $feature.LOCATIONID + "-" + $feature.EQUIPMENTID;
    }
} 

Some reasons why Joe's code did not work is:

  • When using a variable it should always be declared: so line 1 should be var joinChar = "-"
  • When using if the condition should always be inside brackets.

For Karina's expression, it is important that you access the attributes using either $feature.FieldName or $feature["FieldName"]. It is not possible to use [FieldName] in Arcade.

JoeBorgione
MVP Emeritus

When using a variable it should always be declared: so line 1 should be var joinChar = "-"

hahaha; that's the pythonsita in me shining through...

That should just about do it....
XanderBakker
Esri Esteemed Contributor

Don't worry jborgion , this will probably happen again in the future. It has happend to me countless times and when I have errores in my expressions it is the first thing I look for. 

KarinaLivingston
Occasional Contributor

Thanks Joe and Xander, 

I appreciate you guys helping me out. I can't use Arcade because I am using the Attribute Assistant for ArcMap. I have to input the expression into the Dynamic Value table in the Value Info field. The syntax I have been using is from the posts I have found online and online documentation. 

I'm going to try some of these variations to see if it works. 

Thanks

0 Kudos
JoeBorgione
MVP Emeritus

Oh shoot!  My blunder!  I've been using attribute rules extensively along with arcade so when I read your post, that's what I was thinking, not attribute assistant.  My apologies.

In this case, I would avoid the whole generate ID approach and try a nested IIF() function , but looking at he online help for AA, the IIF() explicitly states ' ...functions cannot be used on Null values.'

What if you were to first calc all your <Nulll> values to equal '' (blank, not null) or 'NA' and then use the IIF () function that way.  (Personally I'm not a fan of blank values, so I'd prefer NA or some other notation).  As I recall, the IIF() function in AA can be challenging (at least for me they were), so first play with it so one half of your desired results work, and then 'nest' the the next part in.

Again, sorry for chasing down the wrong rabbit hole.

That should just about do it....
XanderBakker
Esri Esteemed Contributor

Hi klivi001FPUA ,

Please keep in mind that ArcMap + Attribute Assistant is being replaced by ArcGIS Pro +  Attribute Rules. At some point you will want to start moving things over.