adding new values to a new field based off previous field in same layer (query)

1063
6
10-27-2016 01:51 PM
Lake_Worth_BeachAdmin
Occasional Contributor III

I have a layer, I am trying to merge multiple values (multi family, multi family <10) from field 1 into a newly created field 2 as the same value (MF). I have over 50,000 records of this so I was wondering if im in an edit session will the attribute query work for this? Haven't had much luck so far. or maybe another tool will execute this. 

field 1 has multi family and multi family < 10 (along with 50 other value types)

field is currently all NULL.

I want so select the values from field 1 that are  multi family and multi family <10 and create a new value in field 2 as 'MF'.

0 Kudos
6 Replies
DarrenWiens2
MVP Honored Contributor

I don't quite get what you're trying to do. Can you give a simple example showing exactly what you want the result to be?

I think what you're trying to do is:

1.) Select the rows where field1 = 'multi-family' AND multifamily < 10: Selecting records in a table by attributes—Help | ArcGIS for Desktop 

2.) Calculate "MF" into field2: Fundamentals of field calculations—Help | ArcGIS for Desktop 

0 Kudos
Lake_Worth_BeachAdmin
Occasional Contributor III

So my table consists of multiple fields, lets say field 1 is labeled "purpose" and has 20 unique values. Of those 20 unique values two are "multi family," and "multi family <10". 

Now I created a new field named "XXX" I want to calculate this new field with a new values ).

So where field 1 = multi family i want field two to = mf. where field 1 value = multi family <10' i want field two to = mf. 

if field 1 == 'multi family' then write new value for field two as 'mf' 

I am trying to write an expression (was using python but if you can help with vb.script that would work as well) in the field calculator tool. 

Hope this better explains my situation. 

0 Kudos
DarrenWiens2
MVP Honored Contributor

Probably the easiest way to do this is to first select the values that you want to change to 'mf'. The SQL to select these rows would be:

field1 = 'multi family' OR field1 = 'multi familty <10'

...or you could use:

field1 IN ('multi family','multi family <10')

Then, run field calculator to make field2 for those rows equal "mf" - field calculator only operates on selected records if there is a selection.

You could also run a custom function in the field calculator that evaluates whether field1 = 'multi family' or 'multi family <10', but it's a little more complicated.

0 Kudos
Lake_Worth_BeachAdmin
Occasional Contributor III

Sweet thank you for the answer, this method works perfectly for my needs. 

0 Kudos
Lake_Worth_BeachAdmin
Occasional Contributor III

Thanks this was the method I actually used for my needs for this specific request! Definitely saved me a lot of time! 

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

Open the field calculator on field2 and paste the following in the field calculator expression block (replace field1 with the actual field name):

'MF' if !field1! in ('multi family', 'multi family < 10') else None