IIF expression for attribute assistant

789
2
05-31-2019 10:17 AM
BrianHumphries1
New Contributor III

I am trying to calculate a field using the attribute assistant using the Dynamic Value table. 

I want to check the MainHeading Field and if the value of the field falls in between two values Calculate Yes or NO 

If the value is between 166 and 195 I want the field to be populated with a Yes

If the value is not between those values I want to field the populated with a NO

Below is the what I have tried, but I keep getting the same results as YES for all values even the ones that are not in between the 166 and 195 range.

IIF([MainHeading] >= 166 & [MainHeading] <=195, "YES", "NO")

I am sure I have something wrong but I cannot figure it out.

I know someone on here can solve this.

Thanks

0 Kudos
2 Replies
RobertBorchert
Frequent Contributor III

Is mainheading an integer, double, or string?

If it is a double 

IIF([MainHeading] >= 166.0 & [MainHeading] <=195.0, "YES", "NO")

 if it is a string

IIF([MainHeading] >= "166" & [MainHeading] <="195", "YES", "NO")

Are any of the Mainheadings <Null>  if so try putting something in there

Now the dumb question:  Do you have any values less than 166 and or greater than 195

BrianHumphries1
New Contributor III

Thanks, Robert

I was able to figure out what I was doing wrong. I wanted to be able to get the direction of the main to figure out the downstream invert of a manhole to auto-populate the downstream invert of my main. To do this I added a couple of fields to store the angle and the heading.

MainHeading to store the Angle

DSHeading to store the Flow Direction

I ended up using this as my expression to store the Direction of flow in the DSHeading Field.

IIF([MainHeading]<=22.5, "S", IIF([MainHeading]<=67.5, "SW", IIF([MainHeading]<=112.5, "W", IIF([MainHeading]<=157.5, "NW", IIF([MainHeading]<=202.5, "N", IIF([MainHeading]<=247.5, "NE", IIF([MainHeading]<=292.5, "E", IIF([MainHeading]<=337.5, "SE", IIF([MainHeading]<=360, "S", "<Null>")))))))))
0 Kudos