Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I'm a student at Millersville University, PA studying for a BA in Geography with a concentration in GIS. I've stumbled across this site for questions I've had over the past year or so with getting introduced to ArcGIS. So thank you all here for helping a student out :)

I have come across a problem that I can't figure out and my textbook didn't offer any help so I'm hoping one of you can.

I have a table which consists of 3 attribute joins, and I have a text field which has 2 unique values. I want to create a field in which I can summarize the number of times a particular text occours.

For Example: Jx = Join #

ObjectID 1 |J1: A | J2: A | J3: B | CountFldA: 2
ObjectID 2 |J1: B | J2: B | J3: A | CountFldA: 1

I have a feeling that the answer lies somewhere in python but I have no formal experience in it.

Thanks for any insight in advance! wxmeddler from Millersville.

share|improve this question
    
welcome to the site! Have you taken a look at the frequency tool? –  Stephen Lead Sep 27 '12 at 4:59
    
@ Stephen Lead Close, the frequency is defined on the link you gave as _"Reads a table and a set of fields and creates a new table containing unique field values and the number of occurrences of each unique field value."_ What I'm looking for is the frequency across the record. Instead of counting down, I'm counting across. Complicated by the fact that it's a text field. –  wxmeddler Sep 27 '12 at 7:44
    
ah, that makes sense - sorry I missed that crucial detail. The way to approach this will be to iterate through each record using an ArcPy SearchCursor, and analyse the values in-memory. I'll write some pseudo-code in the morning if you haven't solved it by then :) –  Stephen Lead Sep 27 '12 at 10:11
    
Rayner's answer is great - I should have said "one way to approach this" since his is faster. –  Stephen Lead Sep 27 '12 at 22:49

1 Answer 1

up vote 1 down vote accepted

You could concatenate multiple fields together into a new combined field and use 'InStr' inside the Field Calculator (VBScript) to count the number of occurrences of a specific character or string. For example, instr([Combined],"A") would return the number of "A"s in the Combined field. Or I suppose you could use InStr on each individual joined field and then add them up. instr([Field1],"A") + instr([Field2,"A") and so on.

share|improve this answer
1  
Perfect @Rayner! This did exactly what I wanted... The VBscript ended up looking like: InStr( [cd111.PARTY] , "Democrat") + InStr( [cd110.PARTY], "Democrat" ) +InStr( [cd109.PARTY] , "Democrat" ) –  wxmeddler Sep 27 '12 at 13:22
    
Glad I could help you @wxmeddler Don't forget to click the check mark to set this answer as your accepted answer. You can also click the up arrow to indicate that the answer is useful. –  Rayner Sep 27 '12 at 13:32

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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