UrbisMelbourne

ArcGIS 10 - Field Calculator code block help (count and number unique values)

Discussion created by UrbisMelbourne on Mar 17, 2011
Latest reply on Mar 30, 2011 by UrbisMelbourne
I'm putting together a model, and the step I'm stuck on involves the calculation of two new integer fields based on an existing string field/column.  The relevant field might have rows that might look like this:
Row           Color
1                  RED
2                  RED
3                  RED
4                  BLUE
5                  GREEN
6                  GREEN
7                  ORANGE


For the next step of my model, I need to calculate two extra fields, as follows:
Row           Color           ClrCount      ClrOrder
1                  RED                  3                  1
2                  RED                  3                  2
3                  RED                  3                  3
4                  BLUE                1                  1
5                  GREEN              2                  1
6                  GREEN              2                  2
7                  ORANGE            1                  1


"ClrCount" should be the total number of rows in "Color" that share the same string, and should be the same for each of that string's rows.

"ClrOrder" should be a unique number for each of the rows that share the same string.

I don't mind if the code blocks are VBscript or python, but I don't know enough about either to put it together myself.  All I can think is that the solution might involve indexing or creating an array, and then stepping through it somehow.

Any help greatly appreciated!

Outcomes