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

          Wikipedia:Vital articles Мазмуну Biography - Өмүр баян Philosophy and psychology - Философия жана психология Religion - Дин Social sciences - Коомдук илимдер Language and literature - Тил жана адабият Science - Илим Technology - Технология Arts and recreation - Искусство жана эс алуу History and geography - Тарых жана география Навигация менюсу

          Bruxelas-Capital Índice Historia | Composición | Situación lingüística | Clima | Cidades irmandadas | Notas | Véxase tamén | Menú de navegacióneO uso das linguas en Bruxelas e a situación do neerlandés"Rexión de Bruxelas Capital"o orixinalSitio da rexiónPáxina de Bruselas no sitio da Oficina de Promoción Turística de Valonia e BruxelasMapa Interactivo da Rexión de Bruxelas-CapitaleeWorldCat332144929079854441105155190212ID28008674080552-90000 0001 0666 3698n94104302ID540940339365017018237

          What should I write in an apology letter, since I have decided not to join a company after accepting an offer letterShould I keep looking after accepting a job offer?What should I do when I've been verbally told I would get an offer letter, but still haven't gotten one after 4 weeks?Do I accept an offer from a company that I am not likely to join?New job hasn't confirmed starting date and I want to give current employer as much notice as possibleHow should I address my manager in my resignation letter?HR delayed background verification, now jobless as resignedNo email communication after accepting a formal written offer. How should I phrase the call?What should I do if after receiving a verbal offer letter I am informed that my written job offer is put on hold due to some internal issues?Should I inform the current employer that I am about to resign within 1-2 weeks since I have signed the offer letter and waiting for visa?What company will do, if I send their offer letter to another company