I am trying to copy selected values from several columns to one single column in the attribute table.

Specifically, where columns (Grid_code, grid_code1, grid_code2.... etc) have values of 4 and 10, I want them to be copied to a new column, but to ignore all other values (which are all 0s).

This image illustrates roughly what I'm trying to do (in reality there are more columns and rows!)

enter image description here

I think I should do this in field calculator, but can't work out how- I'm inexperienced with VB and Python.

I'm using ArcGIS 10.3.1 for Desktop.

  • 2
    Are the values you want to ignore always 0? In that case you could just sum column1 and column2. – Kersten Nov 4 '15 at 11:26
  • Do you have any cases where column1 and column2 both have values > 0 for a given row? – artwork21 Nov 4 '15 at 12:43
  • What about when 10 and 4 are in the same row? Do you add them? Pick just one? Put 10, 4? What about when neither a 10 or a 4 is in the row? Put nothing? What field type is the output? – ianbroad Nov 5 '15 at 3:59

It is not clear what the precise algorithm you wish to apply to your calculation is but it looks to me like there is no need for Python (or VBscript).

It seems to me that you just need to use the Field Calculator to do:

Output =

!Column1! + !Column2!

The precise delimiters will depend on whether your data is in a file geodatabase (like above) or stored elsewhere.

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.