Doing COUNTIFS equivalent in ArcGIS Field Calculator?VBA functions use in ArcGIS Field CalculatorField calculator fails when computing First X coordinate in ArcGIS10Join and Field CalculatorAdding certain number for each community with QGIS field calculator?Using Field Calculator to assign consecutive numbers to a field based on attributes in another fieldUsing Field Calculator in ArcMap?Using Field calculator to populate fieldCalculate number of alpha characters in field to a new integer field - ArcGISArcGIS Field Calculator Not Working With Date FieldQuerying multiple values in field using ArcGIS ModelBuilder?

Dmesg full of I/O errors, smart ok, four disks affected

Did the CIA blow up a Siberian pipeline in 1982?

Is there a term for the belief that "if it's legal, it's moral"?

Rejecting an offer after accepting it just 10 days from date of joining

How many people are necessary to maintain modern civilisation?

Can I enter the UK for 24 hours from a Schengen area, holding an Indian passport?

How can I prevent a user from copying files on another hard drive?

Non-misogynistic way to say “asshole”?

Is there any proof that high saturation and contrast makes a picture more appealing in social media?

Dates on degrees don’t make sense – will people care?

Why isn't my calculation that we should be able to see the sun well beyond the observable universe valid?

Covering index used despite missing column

What are the current battlegrounds for people’s “rights” in the UK?

Syntax and semantics of XDV commands (XeTeX)

What was the first third-party commercial application for MS-DOS?

Boss wants someone else to lead a project based on the idea I presented to him

Is there a difference between an NFC and RFID chip?

Too early in the morning to have SODA?

What is "industrial ethernet"?

How does DC work with natural 20?

Print one file per line using echo

Prisoner on alien planet escapes by making up a story about ghost companions and wins the war

How much steel armor can you wear and still be able to swim?

What does it cost to buy a tavern?



Doing COUNTIFS equivalent in ArcGIS Field Calculator?


VBA functions use in ArcGIS Field CalculatorField calculator fails when computing First X coordinate in ArcGIS10Join and Field CalculatorAdding certain number for each community with QGIS field calculator?Using Field Calculator to assign consecutive numbers to a field based on attributes in another fieldUsing Field Calculator in ArcMap?Using Field calculator to populate fieldCalculate number of alpha characters in field to a new integer field - ArcGISArcGIS Field Calculator Not Working With Date FieldQuerying multiple values in field using ArcGIS ModelBuilder?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








3















I have an attribute table with location data for a series of individual animals. They are often found at the same locations, so I have created a column in my attribute table where I list the rock ID. The Rock Id counts are repeated for each animal in order to keep data collection simple in the field, so rock 1 for animal 1 is not the same as rock 1 for animal 2. (In any instance where two animals used the same rock - I combined the rock id numbering system for their rocks, but this was rare.) I would like to get a count for the number of times an animal is found at each rock, so I can use symbology on my map that varies in size based on this attribute. (More times an animal uses a rock, larger the symbol).



I have a data set that looks something like this and I want to populate rock count to look something like what I have below



ideal data set up



I know I can use CountIFS in excel - and then potentially import this in, but Ideally I could calculate this for the data already in ArcGIS using code and the field calculator. The summarize tool works well for telling me the unique totals with two case fields- but I would like to replicate this value in each cell. The output of that table is smaller than my original, since obviously there are some repeats.



I don't think I can do a join from this summary table, because each possible joining attribute (Rock_ID, Animal_ID) has more than one row in both tables.










share|improve this question






























    3















    I have an attribute table with location data for a series of individual animals. They are often found at the same locations, so I have created a column in my attribute table where I list the rock ID. The Rock Id counts are repeated for each animal in order to keep data collection simple in the field, so rock 1 for animal 1 is not the same as rock 1 for animal 2. (In any instance where two animals used the same rock - I combined the rock id numbering system for their rocks, but this was rare.) I would like to get a count for the number of times an animal is found at each rock, so I can use symbology on my map that varies in size based on this attribute. (More times an animal uses a rock, larger the symbol).



    I have a data set that looks something like this and I want to populate rock count to look something like what I have below



    ideal data set up



    I know I can use CountIFS in excel - and then potentially import this in, but Ideally I could calculate this for the data already in ArcGIS using code and the field calculator. The summarize tool works well for telling me the unique totals with two case fields- but I would like to replicate this value in each cell. The output of that table is smaller than my original, since obviously there are some repeats.



    I don't think I can do a join from this summary table, because each possible joining attribute (Rock_ID, Animal_ID) has more than one row in both tables.










    share|improve this question


























      3












      3








      3








      I have an attribute table with location data for a series of individual animals. They are often found at the same locations, so I have created a column in my attribute table where I list the rock ID. The Rock Id counts are repeated for each animal in order to keep data collection simple in the field, so rock 1 for animal 1 is not the same as rock 1 for animal 2. (In any instance where two animals used the same rock - I combined the rock id numbering system for their rocks, but this was rare.) I would like to get a count for the number of times an animal is found at each rock, so I can use symbology on my map that varies in size based on this attribute. (More times an animal uses a rock, larger the symbol).



      I have a data set that looks something like this and I want to populate rock count to look something like what I have below



      ideal data set up



      I know I can use CountIFS in excel - and then potentially import this in, but Ideally I could calculate this for the data already in ArcGIS using code and the field calculator. The summarize tool works well for telling me the unique totals with two case fields- but I would like to replicate this value in each cell. The output of that table is smaller than my original, since obviously there are some repeats.



      I don't think I can do a join from this summary table, because each possible joining attribute (Rock_ID, Animal_ID) has more than one row in both tables.










      share|improve this question
















      I have an attribute table with location data for a series of individual animals. They are often found at the same locations, so I have created a column in my attribute table where I list the rock ID. The Rock Id counts are repeated for each animal in order to keep data collection simple in the field, so rock 1 for animal 1 is not the same as rock 1 for animal 2. (In any instance where two animals used the same rock - I combined the rock id numbering system for their rocks, but this was rare.) I would like to get a count for the number of times an animal is found at each rock, so I can use symbology on my map that varies in size based on this attribute. (More times an animal uses a rock, larger the symbol).



      I have a data set that looks something like this and I want to populate rock count to look something like what I have below



      ideal data set up



      I know I can use CountIFS in excel - and then potentially import this in, but Ideally I could calculate this for the data already in ArcGIS using code and the field calculator. The summarize tool works well for telling me the unique totals with two case fields- but I would like to replicate this value in each cell. The output of that table is smaller than my original, since obviously there are some repeats.



      I don't think I can do a join from this summary table, because each possible joining attribute (Rock_ID, Animal_ID) has more than one row in both tables.







      arcgis-desktop field-calculator attribute-joins






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jun 3 at 4:12









      PolyGeo

      54.4k1784253




      54.4k1784253










      asked Jun 3 at 3:33









      Brad-NissenBrad-Nissen

      184




      184




















          2 Answers
          2






          active

          oldest

          votes


















          4














          You can use python with Collections.Counter library to Count unique combinations of Animal_ID & Rock_ID:




          A Counter is a dict subclass for counting hashable objects.




          It is possible to do this using Field Calculator but I recommend using cursors instead. Adjust input fc and field names and execute in Python Window:



          import arcpy
          from collections import Counter

          fc = 'animals' #In the example screenshot a layer. Can also be a shapefile or fc in database, for example fc = r'C:data.gdbanimals'

          c = Counter()

          #Store counts in dictionary
          with arcpy.da.SearchCursor(fc, ['Animal_ID','Rock_ID']) as cursor:
          for row in cursor:
          c[row]+=1

          #Update count column
          with arcpy.da.UpdateCursor(fc,['Animal_ID','Rock_ID','Rock_Count']) as cursor:
          for row in cursor:
          row[2] = c[tuple(row[:2])]
          cursor.updateRow(row)


          Example in ArcGIS Pro, it is the same in ArcMap:
          enter image description here






          share|improve this answer




















          • 1





            Like the use of Counter() never used that before.

            – Hornbydd
            Jun 3 at 8:56






          • 1





            This is a better answer than mine!

            – Son of a Beach
            Jun 3 at 22:33











          • @SonofaBeach your answer is also nice, can be done with standard Tools (=no python)

            – BERA
            Jun 4 at 4:46






          • 1





            It took a bit of tweaking for this novice to run the code, but this did the trick, and was exactly why I turned to Stack - thank you!! I am impressed, and hope this can be helpful to others as well.

            – Brad-Nissen
            Jun 5 at 3:04


















          4














          You need a field that uniquely identifies each combination of animal and rock. Then you can use the Summary tool, and join the summary table back to the original table based on that unique field. Then you can calculate the count field based on the joined summary data:



          • Create a new field, such as "Animal_Rock_ID" and calculate its value as a concatenation of 'Animal_ID' and 'Rock_ID' (with an underscore between the two, to make sure that a 11 and 1 as well as a 1 and 11 don't end up both being the same "111", but would be "11_1" and "1_11" instead). One way to do this in Python would be: "_".format(!Animal_ID!, !Rock_ID!)


          • Run the summary tool.


          • Add a join on your original feature class to the summary table, based on the 'Animal_Rock_ID' field in both.


          • Calculate the field values in your original table from the joined summary field.


          • Remove the join.


          • Optionally, delete the 'Animal_Rock_ID' field (if you have no further or future use for it).






          share|improve this answer

























          • This seems like it would work great - but I have foolishly stored these unique IDs for both Animal_ID and Rock_ID as integers. I tried using .str(!Animal_ID!) + '_' + .str(!Rock_ID!) to convert them to strings - but I keep getting an invalid syntax message - I'm new so I'm sure its simple, but a nudge in the right direction would be appreciated! Tysm

            – Brad-Nissen
            Jun 5 at 2:49






          • 1





            There are a few ways to do it. Removing the . from your str() may help. But I usually use the following: "_".format(!Animal_ID!, !Rock_ID!) . This uses variable interpolation to replace the pairs with the parameters in the format() function. Without using any of the many available options, it simply replaces them in the order that they appear. I have added this to the answer now. BTW, storing IDs as integers is good practice, especially if you need to do database searches on them. Integers are quickest for database searching, with or without database indexes.

            – Son of a Beach
            Jun 5 at 2:51












          • Thanks for this clarification! I managed to get the column I was looking for with the code from @BERA - but I went ahead and created this column - as it may be useful for future analysis. This formatting did the trick - and I will definitely be using it more in the future. Also thanks for the affirmation on my choice to list the IDs as integers. Thank you!

            – Brad-Nissen
            Jun 5 at 3:20











          Your Answer








          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "79"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f324625%2fdoing-countifs-equivalent-in-arcgis-field-calculator%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          4














          You can use python with Collections.Counter library to Count unique combinations of Animal_ID & Rock_ID:




          A Counter is a dict subclass for counting hashable objects.




          It is possible to do this using Field Calculator but I recommend using cursors instead. Adjust input fc and field names and execute in Python Window:



          import arcpy
          from collections import Counter

          fc = 'animals' #In the example screenshot a layer. Can also be a shapefile or fc in database, for example fc = r'C:data.gdbanimals'

          c = Counter()

          #Store counts in dictionary
          with arcpy.da.SearchCursor(fc, ['Animal_ID','Rock_ID']) as cursor:
          for row in cursor:
          c[row]+=1

          #Update count column
          with arcpy.da.UpdateCursor(fc,['Animal_ID','Rock_ID','Rock_Count']) as cursor:
          for row in cursor:
          row[2] = c[tuple(row[:2])]
          cursor.updateRow(row)


          Example in ArcGIS Pro, it is the same in ArcMap:
          enter image description here






          share|improve this answer




















          • 1





            Like the use of Counter() never used that before.

            – Hornbydd
            Jun 3 at 8:56






          • 1





            This is a better answer than mine!

            – Son of a Beach
            Jun 3 at 22:33











          • @SonofaBeach your answer is also nice, can be done with standard Tools (=no python)

            – BERA
            Jun 4 at 4:46






          • 1





            It took a bit of tweaking for this novice to run the code, but this did the trick, and was exactly why I turned to Stack - thank you!! I am impressed, and hope this can be helpful to others as well.

            – Brad-Nissen
            Jun 5 at 3:04















          4














          You can use python with Collections.Counter library to Count unique combinations of Animal_ID & Rock_ID:




          A Counter is a dict subclass for counting hashable objects.




          It is possible to do this using Field Calculator but I recommend using cursors instead. Adjust input fc and field names and execute in Python Window:



          import arcpy
          from collections import Counter

          fc = 'animals' #In the example screenshot a layer. Can also be a shapefile or fc in database, for example fc = r'C:data.gdbanimals'

          c = Counter()

          #Store counts in dictionary
          with arcpy.da.SearchCursor(fc, ['Animal_ID','Rock_ID']) as cursor:
          for row in cursor:
          c[row]+=1

          #Update count column
          with arcpy.da.UpdateCursor(fc,['Animal_ID','Rock_ID','Rock_Count']) as cursor:
          for row in cursor:
          row[2] = c[tuple(row[:2])]
          cursor.updateRow(row)


          Example in ArcGIS Pro, it is the same in ArcMap:
          enter image description here






          share|improve this answer




















          • 1





            Like the use of Counter() never used that before.

            – Hornbydd
            Jun 3 at 8:56






          • 1





            This is a better answer than mine!

            – Son of a Beach
            Jun 3 at 22:33











          • @SonofaBeach your answer is also nice, can be done with standard Tools (=no python)

            – BERA
            Jun 4 at 4:46






          • 1





            It took a bit of tweaking for this novice to run the code, but this did the trick, and was exactly why I turned to Stack - thank you!! I am impressed, and hope this can be helpful to others as well.

            – Brad-Nissen
            Jun 5 at 3:04













          4












          4








          4







          You can use python with Collections.Counter library to Count unique combinations of Animal_ID & Rock_ID:




          A Counter is a dict subclass for counting hashable objects.




          It is possible to do this using Field Calculator but I recommend using cursors instead. Adjust input fc and field names and execute in Python Window:



          import arcpy
          from collections import Counter

          fc = 'animals' #In the example screenshot a layer. Can also be a shapefile or fc in database, for example fc = r'C:data.gdbanimals'

          c = Counter()

          #Store counts in dictionary
          with arcpy.da.SearchCursor(fc, ['Animal_ID','Rock_ID']) as cursor:
          for row in cursor:
          c[row]+=1

          #Update count column
          with arcpy.da.UpdateCursor(fc,['Animal_ID','Rock_ID','Rock_Count']) as cursor:
          for row in cursor:
          row[2] = c[tuple(row[:2])]
          cursor.updateRow(row)


          Example in ArcGIS Pro, it is the same in ArcMap:
          enter image description here






          share|improve this answer















          You can use python with Collections.Counter library to Count unique combinations of Animal_ID & Rock_ID:




          A Counter is a dict subclass for counting hashable objects.




          It is possible to do this using Field Calculator but I recommend using cursors instead. Adjust input fc and field names and execute in Python Window:



          import arcpy
          from collections import Counter

          fc = 'animals' #In the example screenshot a layer. Can also be a shapefile or fc in database, for example fc = r'C:data.gdbanimals'

          c = Counter()

          #Store counts in dictionary
          with arcpy.da.SearchCursor(fc, ['Animal_ID','Rock_ID']) as cursor:
          for row in cursor:
          c[row]+=1

          #Update count column
          with arcpy.da.UpdateCursor(fc,['Animal_ID','Rock_ID','Rock_Count']) as cursor:
          for row in cursor:
          row[2] = c[tuple(row[:2])]
          cursor.updateRow(row)


          Example in ArcGIS Pro, it is the same in ArcMap:
          enter image description here







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Jun 3 at 8:35

























          answered Jun 3 at 7:33









          BERABERA

          18.8k62146




          18.8k62146







          • 1





            Like the use of Counter() never used that before.

            – Hornbydd
            Jun 3 at 8:56






          • 1





            This is a better answer than mine!

            – Son of a Beach
            Jun 3 at 22:33











          • @SonofaBeach your answer is also nice, can be done with standard Tools (=no python)

            – BERA
            Jun 4 at 4:46






          • 1





            It took a bit of tweaking for this novice to run the code, but this did the trick, and was exactly why I turned to Stack - thank you!! I am impressed, and hope this can be helpful to others as well.

            – Brad-Nissen
            Jun 5 at 3:04












          • 1





            Like the use of Counter() never used that before.

            – Hornbydd
            Jun 3 at 8:56






          • 1





            This is a better answer than mine!

            – Son of a Beach
            Jun 3 at 22:33











          • @SonofaBeach your answer is also nice, can be done with standard Tools (=no python)

            – BERA
            Jun 4 at 4:46






          • 1





            It took a bit of tweaking for this novice to run the code, but this did the trick, and was exactly why I turned to Stack - thank you!! I am impressed, and hope this can be helpful to others as well.

            – Brad-Nissen
            Jun 5 at 3:04







          1




          1





          Like the use of Counter() never used that before.

          – Hornbydd
          Jun 3 at 8:56





          Like the use of Counter() never used that before.

          – Hornbydd
          Jun 3 at 8:56




          1




          1





          This is a better answer than mine!

          – Son of a Beach
          Jun 3 at 22:33





          This is a better answer than mine!

          – Son of a Beach
          Jun 3 at 22:33













          @SonofaBeach your answer is also nice, can be done with standard Tools (=no python)

          – BERA
          Jun 4 at 4:46





          @SonofaBeach your answer is also nice, can be done with standard Tools (=no python)

          – BERA
          Jun 4 at 4:46




          1




          1





          It took a bit of tweaking for this novice to run the code, but this did the trick, and was exactly why I turned to Stack - thank you!! I am impressed, and hope this can be helpful to others as well.

          – Brad-Nissen
          Jun 5 at 3:04





          It took a bit of tweaking for this novice to run the code, but this did the trick, and was exactly why I turned to Stack - thank you!! I am impressed, and hope this can be helpful to others as well.

          – Brad-Nissen
          Jun 5 at 3:04













          4














          You need a field that uniquely identifies each combination of animal and rock. Then you can use the Summary tool, and join the summary table back to the original table based on that unique field. Then you can calculate the count field based on the joined summary data:



          • Create a new field, such as "Animal_Rock_ID" and calculate its value as a concatenation of 'Animal_ID' and 'Rock_ID' (with an underscore between the two, to make sure that a 11 and 1 as well as a 1 and 11 don't end up both being the same "111", but would be "11_1" and "1_11" instead). One way to do this in Python would be: "_".format(!Animal_ID!, !Rock_ID!)


          • Run the summary tool.


          • Add a join on your original feature class to the summary table, based on the 'Animal_Rock_ID' field in both.


          • Calculate the field values in your original table from the joined summary field.


          • Remove the join.


          • Optionally, delete the 'Animal_Rock_ID' field (if you have no further or future use for it).






          share|improve this answer

























          • This seems like it would work great - but I have foolishly stored these unique IDs for both Animal_ID and Rock_ID as integers. I tried using .str(!Animal_ID!) + '_' + .str(!Rock_ID!) to convert them to strings - but I keep getting an invalid syntax message - I'm new so I'm sure its simple, but a nudge in the right direction would be appreciated! Tysm

            – Brad-Nissen
            Jun 5 at 2:49






          • 1





            There are a few ways to do it. Removing the . from your str() may help. But I usually use the following: "_".format(!Animal_ID!, !Rock_ID!) . This uses variable interpolation to replace the pairs with the parameters in the format() function. Without using any of the many available options, it simply replaces them in the order that they appear. I have added this to the answer now. BTW, storing IDs as integers is good practice, especially if you need to do database searches on them. Integers are quickest for database searching, with or without database indexes.

            – Son of a Beach
            Jun 5 at 2:51












          • Thanks for this clarification! I managed to get the column I was looking for with the code from @BERA - but I went ahead and created this column - as it may be useful for future analysis. This formatting did the trick - and I will definitely be using it more in the future. Also thanks for the affirmation on my choice to list the IDs as integers. Thank you!

            – Brad-Nissen
            Jun 5 at 3:20















          4














          You need a field that uniquely identifies each combination of animal and rock. Then you can use the Summary tool, and join the summary table back to the original table based on that unique field. Then you can calculate the count field based on the joined summary data:



          • Create a new field, such as "Animal_Rock_ID" and calculate its value as a concatenation of 'Animal_ID' and 'Rock_ID' (with an underscore between the two, to make sure that a 11 and 1 as well as a 1 and 11 don't end up both being the same "111", but would be "11_1" and "1_11" instead). One way to do this in Python would be: "_".format(!Animal_ID!, !Rock_ID!)


          • Run the summary tool.


          • Add a join on your original feature class to the summary table, based on the 'Animal_Rock_ID' field in both.


          • Calculate the field values in your original table from the joined summary field.


          • Remove the join.


          • Optionally, delete the 'Animal_Rock_ID' field (if you have no further or future use for it).






          share|improve this answer

























          • This seems like it would work great - but I have foolishly stored these unique IDs for both Animal_ID and Rock_ID as integers. I tried using .str(!Animal_ID!) + '_' + .str(!Rock_ID!) to convert them to strings - but I keep getting an invalid syntax message - I'm new so I'm sure its simple, but a nudge in the right direction would be appreciated! Tysm

            – Brad-Nissen
            Jun 5 at 2:49






          • 1





            There are a few ways to do it. Removing the . from your str() may help. But I usually use the following: "_".format(!Animal_ID!, !Rock_ID!) . This uses variable interpolation to replace the pairs with the parameters in the format() function. Without using any of the many available options, it simply replaces them in the order that they appear. I have added this to the answer now. BTW, storing IDs as integers is good practice, especially if you need to do database searches on them. Integers are quickest for database searching, with or without database indexes.

            – Son of a Beach
            Jun 5 at 2:51












          • Thanks for this clarification! I managed to get the column I was looking for with the code from @BERA - but I went ahead and created this column - as it may be useful for future analysis. This formatting did the trick - and I will definitely be using it more in the future. Also thanks for the affirmation on my choice to list the IDs as integers. Thank you!

            – Brad-Nissen
            Jun 5 at 3:20













          4












          4








          4







          You need a field that uniquely identifies each combination of animal and rock. Then you can use the Summary tool, and join the summary table back to the original table based on that unique field. Then you can calculate the count field based on the joined summary data:



          • Create a new field, such as "Animal_Rock_ID" and calculate its value as a concatenation of 'Animal_ID' and 'Rock_ID' (with an underscore between the two, to make sure that a 11 and 1 as well as a 1 and 11 don't end up both being the same "111", but would be "11_1" and "1_11" instead). One way to do this in Python would be: "_".format(!Animal_ID!, !Rock_ID!)


          • Run the summary tool.


          • Add a join on your original feature class to the summary table, based on the 'Animal_Rock_ID' field in both.


          • Calculate the field values in your original table from the joined summary field.


          • Remove the join.


          • Optionally, delete the 'Animal_Rock_ID' field (if you have no further or future use for it).






          share|improve this answer















          You need a field that uniquely identifies each combination of animal and rock. Then you can use the Summary tool, and join the summary table back to the original table based on that unique field. Then you can calculate the count field based on the joined summary data:



          • Create a new field, such as "Animal_Rock_ID" and calculate its value as a concatenation of 'Animal_ID' and 'Rock_ID' (with an underscore between the two, to make sure that a 11 and 1 as well as a 1 and 11 don't end up both being the same "111", but would be "11_1" and "1_11" instead). One way to do this in Python would be: "_".format(!Animal_ID!, !Rock_ID!)


          • Run the summary tool.


          • Add a join on your original feature class to the summary table, based on the 'Animal_Rock_ID' field in both.


          • Calculate the field values in your original table from the joined summary field.


          • Remove the join.


          • Optionally, delete the 'Animal_Rock_ID' field (if you have no further or future use for it).







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Jun 5 at 2:54

























          answered Jun 3 at 3:48









          Son of a BeachSon of a Beach

          2,278821




          2,278821












          • This seems like it would work great - but I have foolishly stored these unique IDs for both Animal_ID and Rock_ID as integers. I tried using .str(!Animal_ID!) + '_' + .str(!Rock_ID!) to convert them to strings - but I keep getting an invalid syntax message - I'm new so I'm sure its simple, but a nudge in the right direction would be appreciated! Tysm

            – Brad-Nissen
            Jun 5 at 2:49






          • 1





            There are a few ways to do it. Removing the . from your str() may help. But I usually use the following: "_".format(!Animal_ID!, !Rock_ID!) . This uses variable interpolation to replace the pairs with the parameters in the format() function. Without using any of the many available options, it simply replaces them in the order that they appear. I have added this to the answer now. BTW, storing IDs as integers is good practice, especially if you need to do database searches on them. Integers are quickest for database searching, with or without database indexes.

            – Son of a Beach
            Jun 5 at 2:51












          • Thanks for this clarification! I managed to get the column I was looking for with the code from @BERA - but I went ahead and created this column - as it may be useful for future analysis. This formatting did the trick - and I will definitely be using it more in the future. Also thanks for the affirmation on my choice to list the IDs as integers. Thank you!

            – Brad-Nissen
            Jun 5 at 3:20

















          • This seems like it would work great - but I have foolishly stored these unique IDs for both Animal_ID and Rock_ID as integers. I tried using .str(!Animal_ID!) + '_' + .str(!Rock_ID!) to convert them to strings - but I keep getting an invalid syntax message - I'm new so I'm sure its simple, but a nudge in the right direction would be appreciated! Tysm

            – Brad-Nissen
            Jun 5 at 2:49






          • 1





            There are a few ways to do it. Removing the . from your str() may help. But I usually use the following: "_".format(!Animal_ID!, !Rock_ID!) . This uses variable interpolation to replace the pairs with the parameters in the format() function. Without using any of the many available options, it simply replaces them in the order that they appear. I have added this to the answer now. BTW, storing IDs as integers is good practice, especially if you need to do database searches on them. Integers are quickest for database searching, with or without database indexes.

            – Son of a Beach
            Jun 5 at 2:51












          • Thanks for this clarification! I managed to get the column I was looking for with the code from @BERA - but I went ahead and created this column - as it may be useful for future analysis. This formatting did the trick - and I will definitely be using it more in the future. Also thanks for the affirmation on my choice to list the IDs as integers. Thank you!

            – Brad-Nissen
            Jun 5 at 3:20
















          This seems like it would work great - but I have foolishly stored these unique IDs for both Animal_ID and Rock_ID as integers. I tried using .str(!Animal_ID!) + '_' + .str(!Rock_ID!) to convert them to strings - but I keep getting an invalid syntax message - I'm new so I'm sure its simple, but a nudge in the right direction would be appreciated! Tysm

          – Brad-Nissen
          Jun 5 at 2:49





          This seems like it would work great - but I have foolishly stored these unique IDs for both Animal_ID and Rock_ID as integers. I tried using .str(!Animal_ID!) + '_' + .str(!Rock_ID!) to convert them to strings - but I keep getting an invalid syntax message - I'm new so I'm sure its simple, but a nudge in the right direction would be appreciated! Tysm

          – Brad-Nissen
          Jun 5 at 2:49




          1




          1





          There are a few ways to do it. Removing the . from your str() may help. But I usually use the following: "_".format(!Animal_ID!, !Rock_ID!) . This uses variable interpolation to replace the pairs with the parameters in the format() function. Without using any of the many available options, it simply replaces them in the order that they appear. I have added this to the answer now. BTW, storing IDs as integers is good practice, especially if you need to do database searches on them. Integers are quickest for database searching, with or without database indexes.

          – Son of a Beach
          Jun 5 at 2:51






          There are a few ways to do it. Removing the . from your str() may help. But I usually use the following: "_".format(!Animal_ID!, !Rock_ID!) . This uses variable interpolation to replace the pairs with the parameters in the format() function. Without using any of the many available options, it simply replaces them in the order that they appear. I have added this to the answer now. BTW, storing IDs as integers is good practice, especially if you need to do database searches on them. Integers are quickest for database searching, with or without database indexes.

          – Son of a Beach
          Jun 5 at 2:51














          Thanks for this clarification! I managed to get the column I was looking for with the code from @BERA - but I went ahead and created this column - as it may be useful for future analysis. This formatting did the trick - and I will definitely be using it more in the future. Also thanks for the affirmation on my choice to list the IDs as integers. Thank you!

          – Brad-Nissen
          Jun 5 at 3:20





          Thanks for this clarification! I managed to get the column I was looking for with the code from @BERA - but I went ahead and created this column - as it may be useful for future analysis. This formatting did the trick - and I will definitely be using it more in the future. Also thanks for the affirmation on my choice to list the IDs as integers. Thank you!

          – Brad-Nissen
          Jun 5 at 3:20

















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Geographic Information Systems Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f324625%2fdoing-countifs-equivalent-in-arcgis-field-calculator%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Club Baloncesto Breogán Índice Historia | Pavillón | Nome | O Breogán na cultura popular | Xogadores | Adestradores | Presidentes | Palmarés | Historial | Líderes | Notas | Véxase tamén | Menú de navegacióncbbreogan.galCadroGuía oficial da ACB 2009-10, páxina 201Guía oficial ACB 1992, páxina 183. Editorial DB.É de 6.500 espectadores sentados axeitándose á última normativa"Estudiantes Junior, entre as mellores canteiras"o orixinalHemeroteca El Mundo Deportivo, 16 setembro de 1970, páxina 12Historia do BreogánAlfredo Pérez, o último canoneiroHistoria C.B. BreogánHemeroteca de El Mundo DeportivoJimmy Wright, norteamericano do Breogán deixará Lugo por ameazas de morteResultados de Breogán en 1986-87Resultados de Breogán en 1990-91Ficha de Velimir Perasović en acb.comResultados de Breogán en 1994-95Breogán arrasa al Barça. "El Mundo Deportivo", 27 de setembro de 1999, páxina 58CB Breogán - FC BarcelonaA FEB invita a participar nunha nova Liga EuropeaCharlie Bell na prensa estatalMáximos anotadores 2005Tempada 2005-06 : Tódolos Xogadores da Xornada""Non quero pensar nunha man negra, mais pregúntome que está a pasar""o orixinalRaúl López, orgulloso dos xogadores, presume da boa saúde económica do BreogánJulio González confirma que cesa como presidente del BreogánHomenaxe a Lisardo GómezA tempada do rexurdimento celesteEntrevista a Lisardo GómezEl COB dinamita el Pazo para forzar el quinto (69-73)Cafés Candelas, patrocinador del CB Breogán"Suso Lázare, novo presidente do Breogán"o orixinalCafés Candelas Breogán firma el mayor triunfo de la historiaEl Breogán realizará 17 homenajes por su cincuenta aniversario"O Breogán honra ao seu fundador e primeiro presidente"o orixinalMiguel Giao recibiu a homenaxe do PazoHomenaxe aos primeiros gladiadores celestesO home que nos amosa como ver o Breo co corazónTita Franco será homenaxeada polos #50anosdeBreoJulio Vila recibirá unha homenaxe in memoriam polos #50anosdeBreo"O Breogán homenaxeará aos seus aboados máis veteráns"Pechada ovación a «Capi» Sanmartín e Ricardo «Corazón de González»Homenaxe por décadas de informaciónPaco García volve ao Pazo con motivo do 50 aniversario"Resultados y clasificaciones""O Cafés Candelas Breogán, campión da Copa Princesa""O Cafés Candelas Breogán, equipo ACB"C.B. Breogán"Proxecto social"o orixinal"Centros asociados"o orixinalFicha en imdb.comMario Camus trata la recuperación del amor en 'La vieja música', su última película"Páxina web oficial""Club Baloncesto Breogán""C. B. Breogán S.A.D."eehttp://www.fegaba.com

          Vilaño, A Laracha Índice Patrimonio | Lugares e parroquias | Véxase tamén | Menú de navegación43°14′52″N 8°36′03″O / 43.24775, -8.60070

          Cegueira Índice Epidemioloxía | Deficiencia visual | Tipos de cegueira | Principais causas de cegueira | Tratamento | Técnicas de adaptación e axudas | Vida dos cegos | Primeiros auxilios | Crenzas respecto das persoas cegas | Crenzas das persoas cegas | O neno deficiente visual | Aspectos psicolóxicos da cegueira | Notas | Véxase tamén | Menú de navegación54.054.154.436928256blindnessDicionario da Real Academia GalegaPortal das Palabras"International Standards: Visual Standards — Aspects and Ranges of Vision Loss with Emphasis on Population Surveys.""Visual impairment and blindness""Presentan un plan para previr a cegueira"o orixinalACCDV Associació Catalana de Cecs i Disminuïts Visuals - PMFTrachoma"Effect of gene therapy on visual function in Leber's congenital amaurosis"1844137110.1056/NEJMoa0802268Cans guía - os mellores amigos dos cegosArquivadoEscola de cans guía para cegos en Mortágua, PortugalArquivado"Tecnología para ciegos y deficientes visuales. Recopilación de recursos gratuitos en la Red""Colorino""‘COL.diesis’, escuchar los sonidos del color""COL.diesis: Transforming Colour into Melody and Implementing the Result in a Colour Sensor Device"o orixinal"Sistema de desarrollo de sinestesia color-sonido para invidentes utilizando un protocolo de audio""Enseñanza táctil - geometría y color. Juegos didácticos para niños ciegos y videntes""Sistema Constanz"L'ocupació laboral dels cecs a l'Estat espanyol està pràcticament equiparada a la de les persones amb visió, entrevista amb Pedro ZuritaONCE (Organización Nacional de Cegos de España)Prevención da cegueiraDescrición de deficiencias visuais (Disc@pnet)Braillín, un boneco atractivo para calquera neno, con ou sen discapacidade, que permite familiarizarse co sistema de escritura e lectura brailleAxudas Técnicas36838ID00897494007150-90057129528256DOID:1432HP:0000618D001766C10.597.751.941.162C97109C0155020