title: How to count students number on different conditions in a attendance sheet
body: <p>I have been working on an Excel sheet of school attendance. I have already asked a question about that attendance. Now I have a different situation. I have both “boy(B)/girl(G)” students in Gender section. I also have a Category section having 5 different categories. Now I have dates corresponding to each name of the students where a teacher puts either a “P” or an “A”. Please loot into the image:</p>
  
  <p><a href="https://i.stack.imgur.com/WY9UR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WY9UR.png" alt="Attendance sheet"></a></p>
  
  <p>I need to count total number of students on below conditions:</p>
  
  <ol>
  <li>How many boys were present (at least 1 day) in a month?</li>
  <li>How many girl were present (at least 1 day) in a month?</li>
  <li>How many boys in each category were present (at least 1 day) in a month?</li>
  <li>How many girls in each category were present (at least 1 day) in a month?</li>
  </ol>
  
  <p>Kindly note that the names of the students are not unique.</p>
  
  <p>Please help !</p>
  
  <p>EDIT:</p>
  
  <p>I tried to count "total number of male students (B - in my case) attended at least 1 class in this way:</p>
  
  <pre><code>=COUNTIFS(D5:D49,"B",F5:AJ49,"P")
  </code></pre>
  
  <p>But it is throwing an error.</p>
  
  <p>EDIT:</p>
  
  <p>Thank you all for the responses. But I guess I did not able to make my point clearly. </p>
  
  <p>Here I want to count "How many students were present in all cases and not "how many times each student was present", i.e. I need to count student in all cases who went to school even a single day. So if a student was present let’s say 20 days in a month, the total number will be 1 and not 20. </p>
  
  <p>I hope I made things clear now. </p>
  
  <p>EDIT:</p>
  
  <p>Thank you guys for the help. I have accomplished the task by adding an extra column which returns a 1 if there is any "P" in the date row by using:</p>
  
  <pre><code>=IF((COUNTIF(G5:AK5,"P"))&gt;0,1,0)
  </code></pre>
  
  <p>Then I am using a COUNTIFS with multiple conditions which checks and count if the extra cell (above) have a value of 1 and checks the Gender and Category row and count it:</p>
  
  <pre><code>=COUNTIFS(C5:C27,"&gt;0", E5:E27,"G", F5:F27,"CAT1")
  </code></pre>
  
  <p>Though, I don't want to use the extra cell as it is not needed for attendance purpose. So I asked a different question <a href="https://stackoverflow.com/questions/32038124/can-we-nest-an-if-inside-a-countifs-in-excel">here</a></p>