+ Reply to Thread
Results 1 to 12 of 12

COUNTIF for variables that meets a dynamic criteria

  1. #1
    Registered User
    Join Date
    05-07-2013
    Location
    Singapore
    MS-Off Ver
    Excel 2007
    Posts
    6

    COUNTIF for variables that meets a dynamic criteria

    Hi guys, i'm new to this forum. I seldom need to create excel spreadsheet, so I don't know how to solve this simple solution (which i could with spss).

    I am looking for a non-VBA solution because not all my employees/ clients have VBA-access.

    Problem

    Column A: Group Identifier
    Column B: Test 1 Score
    Column C: Test 2 Score
    Column D: G2 - Group required
    Column E: E2 - Criteria for Test 1 (e.g. >=30)
    Column F: F2 - Criteria for Test 2 (e.g. <=50)
    Column G: G2 - Generated Results

    I want to create a spreadsheet that allows the user to count the number of entries that meets a user-specified criteria, which they can key in on Column E and Column F.

    The user will also be able to identify the group identifier (e.g. class A) for the counting.

    Example the user wants to find out the number of people in class A that scores higher and equal to 30 for Test 1 AND/ OR score lower and equal to 50 for Test 2.

    The user will key in "A" in cell G2, ">=30" in cell E2 and "<=50" in cell F2.

    I tried using COUNTIFS function, but i can't make it work to allow the AND/ OR condition.
    I tried using SUMPRODUCT, but sum product won't allow me to specify the operant (i.e. <=, >=). The direction of operant is important, because the user need to be able to specify the criteria.

    I have added a sample excel sheet.

    Thanks in advance!
    Attached Files Attached Files

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: COUNTIF for variables that meets a dynamic criteria

    In D2 Cell
    A

    In E2 Cell
    >=30

    In F2 Cell
    <=50

    In G2 Cell
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Registered User
    Join Date
    05-07-2013
    Location
    Singapore
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: COUNTIF for variables that meets a dynamic criteria

    Hi sixthsense, thanks for the response, but it is not working as I intended.

    The criteria for the test Score 1 and 2 is supposed to be AND / OR

    The formula you gave me is AND.

    Whereas i need the formula to give me the responses for OR.

    Example, if the criteria is >=30 for Test 1 and <=50 for Test 2

    If the Test 1 and Test 2 scores are:
    40 / 60
    20 / 40
    40 / 40

    The 3 individuals would be counted to fit into the criteria because individual 1 has a test score 1 of higher than 30, individual 2 has a test score 2 of less than 50 and individual 3 has a test score 1 of higher than 30 and test score 2 of less than 50.

  4. #4
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: COUNTIF for variables that meets a dynamic criteria

    May be try like this...

    Formula: copy to clipboard
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    05-07-2013
    Location
    Singapore
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: COUNTIF for variables that meets a dynamic criteria

    Quote Originally Posted by :) Sixthsense :) View Post
    May be try like this...
    Didn't work. This formula will double count an individual if he meets the criteria of test score 1 and test score 2.

    Maybe countif is not the best way to do this? I tried another line of reasoning, by creating a new variable in Column H, using the IF function. Basically the function will return a value of 1 if the Column B values meets criteria in Column E or if Column C values meets criteria in Column F.

    The problem is that the IF function does not support an INDIRECT function, so i can't link it to Column E and Column F values.

  6. #6
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: COUNTIF for variables that meets a dynamic criteria

    You will get the exact solution If you show the data in excel with expected output for better understanding

  7. #7
    Registered User
    Join Date
    05-07-2013
    Location
    Singapore
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: COUNTIF for variables that meets a dynamic criteria

    The sample is actually sufficient... so maybe its my explanation is unclear.

    Ok, i have attached another sample, and then highlighted in red the individuals who should be flagged out by the criteria. The test scores which meet the criteria are also highlighted in red.

    Based on the settings in the yellow box, the correct answer should be 5.

    Thanks for persisting in helping me sixthsense! :D
    Attached Files Attached Files

  8. #8
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: COUNTIF for variables that meets a dynamic criteria

    Still I am not clear about what is your exact problem is since the suggested formula works in the way which you shown in the latest attachment.

    =COUNTIFS($A$2:$A$15,D2,$B$2:$B$15,E2)+COUNTIFS($A$2:$A$15,D2,$C$2:$C$15,F2)

  9. #9
    Registered User
    Join Date
    05-07-2013
    Location
    Singapore
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: COUNTIF for variables that meets a dynamic criteria

    When i used your formula, it gives me the answer 6. The correct answer ought to be 5.

    That is because it counted each occurence of Test 1 meeting criteria, and Test 2 meeting criteria. It essentially double count the same individual, if his test score 1 meets the criteria and test score 2 meets the criteria.

    In sample 2, you will see that the the individual in Row 2 has both tests meeting the criteria. But he is only 1 individual, and he should not be double counted.

    What i want is counting the number of individuals, which means counting the number of red-coloured cell in column A.

  10. #10
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,156

    Re: COUNTIF for variables that meets a dynamic criteria

    hi atomz, welcome to the forum. perhaps this long-winded way might help:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Thanks, if you have clicked on the * and added our rep.

    If you're satisfied with the answer, click Thread Tools above your first post, select "Mark your thread as Solved".

    "Contentment is not the fulfillment of what you want, but the realization of what you already have."


    Tips & Tutorials I Compiled | How to Get Quick & Good Answers

  11. #11
    Registered User
    Join Date
    05-07-2013
    Location
    Singapore
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: COUNTIF for variables that meets a dynamic criteria

    That works benishyro! Thanks!

    P.S. and i noticed you are from Singapore too!

  12. #12
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,156

    Re: COUNTIF for variables that meets a dynamic criteria

    you're very welcome~

    yes i am~

+ 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