+ Reply to Thread
Results 1 to 11 of 11

COUNTIF Confusion

Hybrid View

  1. #1
    Registered User
    Join Date
    11-30-2012
    Location
    Edinburgh
    MS-Off Ver
    Excel 2003
    Posts
    5

    COUNTIF Confusion

    Hi guys,

    I am hoping one of you wizards can help me out?

    I am having trouble with the COUNTIF command! I work in a school and am trying to create stats on behaviour incidents that happen in school. I am trying to generate a breakdown to analyse by gender, and age but have this for each month.

    I have 3 columns that I am working with: ENDER, YEAR GROUP and DATE.

    The Year Group is already validated data from a list on another worksheet defined as REGGP (short for Register groups).
    The date is entered by the teacher to state when the incident occurred.

    I have managed to generate number for each month to count the number of MALES and FEMALES using the following formula. For instance November:
    =SUMPRODUCT(--(D3:D33="Female"),--(F3:F33>=--"2012-11-01"),--(F3:F33<=--"2012-11-30"))
    This counts the number of females and displays a number for November. I have this for each month.


    Now here is where I am stuck.....


    I now want to identify the number of S1 (year 1), S2, S3, S4, S5, S6 pupils that have had a discipline issue for that month. But the formulae I am using always generate a 0! I am using office XP which may be half the problem.

    I have tried the following:

    =COUNTIF(E3:E33,"2*")
    but this counts all the S2 classes but I can't tell which S1 pupil was which month. Fine for an overall count though.

    =SUMPRODUCT(--(E3:E33="=REGGP"),--(F3:F33>=--"2012-11-01"),--(F3:F33<=--"2012-11-30"))
    I thought I could the definded name of my list but this didn't work either.

    =SUMPRODUCT(--(E3:E33={"2A1","2A2","2D1","2D2","2M1","2M2"),--(F3:F33>=--"2012-11-01"),--(F3:F33<=--"2012-11-30"))
    Instead of using the list I tried typing all S2 form classes but noting either.

    But none of them are working?!?!?! Can anybody advise on how I need to tweak my syntax??? I'm sure it is my inexperience. This must be possible!

    Many thanks!

  2. #2
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: COUNTIF Confusion

    I think you get better help if you add your excel file, without confidentional information.

    Please also add the desired result.
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

  3. #3
    Registered User
    Join Date
    05-29-2012
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    84

    Re: COUNTIF Confusion

    Yeah, its tough to figure out exactly what you are trying to do from the explanation above. I'm wondering if you may be able to do something simple like using the "TEXT" function to convert the data into something easier and and then just using some sort of pivot table. As mentioned above, probably need an example sheet to determine this for sure.

  4. #4
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: COUNTIF Confusion

    Seems to me a Pivot Table would work for this.
    Palmetto

    Do you know . . . ?

    You can leave feedback and add to the reputation of all who contributed a helpful response to your solution by clicking the star icon located at the left in one of their post in this thread.

  5. #5
    Registered User
    Join Date
    11-30-2012
    Location
    Edinburgh
    MS-Off Ver
    Excel 2003
    Posts
    5

    Thumbs up Re: COUNTIF Confusion

    BehaviourAnalysis_Model.xls

    File attached. I appreciate a few people responding and thanks for your "Pivot Table" comments. Can you elaborate or direct me to a suitable tutorial?

    Thanks again folks.

  6. #6
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,702

    Re: COUNTIF Confusion

    If you use this formula in N4

    =SUMPRODUCT(--(LEFT($E$3:$E$33)=RIGHT(N$3)),--(TEXT($F$3:$F$33,"mmmm")=$J4))

    you can copy across and down and it will work for the whole table
    Audere est facere

  7. #7
    Registered User
    Join Date
    11-30-2012
    Location
    Edinburgh
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: COUNTIF Confusion

    Thanks very much Daddy Long Legs. It does indeed work. Any chance you can explain the whole LEFT and RIGHT thing? also why the text value "mmmm"???

    Thanks again. Have also tried a pivot table and it too looks like a possible method. The only thing is, because staff would input a date how could I get a monthly output as opposed to a set date?

    Or, much like the online banking systems, can you choose a start date and an end date for analysis??? How would I do that in a pivot table?

    Much appreciated everyone. It is amazing how powerful Excel can be. I have a reporting project that I'd also like to develop. The concept may be better suited to a database but I think Excel could pull it off!
    Last edited by tamedijodbro; 12-01-2012 at 12:01 PM. Reason: Addendum

  8. #8
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: COUNTIF Confusion

    See a solution with an pivot table.

    See the attached file.

  9. #9
    Registered User
    Join Date
    11-30-2012
    Location
    Edinburgh
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: COUNTIF Confusion

    oeldere thank you very much for you version of the table. It looks excellent however with the addition of the MONTH and YEAR column create too much info on the table. Is there a way of having these columns hidden but the pivot table still being able to generate monthly data?

    Can it calculate this just from the DATE column instead???

    Thanks again - I am really impressed by the kindness and knowledge of the member on this forum.

    - JT

  10. #10
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: COUNTIF Confusion

    Yes you can hide the column of month and year; and still get the data in the pivot table.

    You can also show your pivot table on an own worksheet.

  11. #11
    Registered User
    Join Date
    11-30-2012
    Location
    Edinburgh
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: COUNTIF Confusion

    Thanks again everyone. Issue resolved. Got the worksheets to generate all the data/charts I needed.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1