+ Reply to Thread
Results 1 to 13 of 13

Nested if statatement + count

Hybrid View

  1. #1
    Registered User
    Join Date
    07-24-2013
    Location
    new york
    MS-Off Ver
    Excel 2003
    Posts
    62

    Nested if statatement + count

    Hello friends,

    I am new to nested if statement. I will like to see how many people in my data are ELIGIBLE for contraception services and what is the percentage of all my participants. In order for my participants to be ELIGIBLE, they have to be currently active, they can not be pregnant, and they can not be seeking pregnancy. My goal is to have a table in tab 2 that summarizes this info (# eligible and % of total). My idea was to create a new column (eligible) in my dataset with the nested if statements. Then in tab , I will count how many are eligible and generate the percentage. What will be a nice way to do this. I want to impress my supervisor.


    Thank you in advance.
    Marvin
    Attached Files Attached Files

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,225

    Re: Nested if statatement + count

    U2 on data sheet:
    Formula: copy to clipboard
    =(I2="yes")*(J2="no")*(K2="no")
    copied down.


    and, in Sheet1:
    B3:
    Formula: copy to clipboard
    COUNTIFS(Data!$I$2:$I$10,"yes", Data!$J$2:$J$10,"no",Data!$K$2:$K$10,"no")

    C3:
    Formula: copy to clipboard
    =COUNTIFS(Data!$I$2:$I$10,"yes", Data!$J$2:$J$10,"no",Data!$K$2:$K$10,"no")/COUNTA(Data!$A$2:$A$10)



    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: Nested if statatement + count

    Not to step on toes, but an alternative to the formula in U2 would be
    =IF((I2="yes")*(J2="no")*(K2="no"),"Yes","No")
    This will give a "Yes" or "No" in the U column
    1N73LL1G3NC3 15 7H3 4B1L17Y 70 4D4P7 70 CH4NG3 - 573PH3N H4WK1NG
    You don't have to add Rep if I have helped you out (but it would be nice), but please mark the thread as SOLVED if your issue is resolved.

    Tom

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,225

    Re: Nested if statatement + count

    No toes trodden on. It's always useful to have different viewpoints

    If you put 1 or 0 in column U, you can just sum them. If you put "yes" or "no" in column U, you then have to use COUNTIF on the summary page.

    Horses for courses. I didn't actually use column U on the Summary page so it really depends what the OP wants to see on the Data sheet. In which case, you don't need the extra column on the Data sheet at all.

    @Marvin85: go impress your supervisor

  5. #5
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: Nested if statatement + count

    After putting the =IF formula into U2, I used the formulas you provided for the Data sheet and it worked out great without changing anything.

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,225

    Re: Nested if statatement + count


  7. #7
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,225

    Re: Nested if statatement + count

    Updated sample workbook ...
    Attached Files Attached Files

  8. #8
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: Nested if statatement + count

    Now the OP has both options to choose from. I'm going to save your updated sample for the COUNTIFS, as I don't have a lot of experience with it.

  9. #9
    Registered User
    Join Date
    07-24-2013
    Location
    new york
    MS-Off Ver
    Excel 2003
    Posts
    62

    Re: Nested if statatement + count

    Wow! Thanks guys.There are many options here. I will make sure that I understand and practices these formulas so I wont bother you so much in the future. Have a nice sunday!

  10. #10
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: Nested if statatement + count

    You're welcome. It's no bother to help out. I/we no how frustrating it can be when you know what you want to do, but can't get anything you try to work correctly.

  11. #11
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,225

    Re: Nested if statatement + count

    You're welcome.



    If you are satisfied with the solution(s) provided, please mark your thread as Solved.


    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save


    You may also want to consider thanking those people who helped you by clicking on the little star at the bottom left of their reply to your question.

  12. #12
    Registered User
    Join Date
    07-24-2013
    Location
    new york
    MS-Off Ver
    Excel 2003
    Posts
    62

    Re: Nested if statatement + count

    Will do TMS. One more thing. The formulas are perfect but the problems is that sometimes my grantees fill the dataset incorrectly. The main purspose if this dataset is to assess contraceptive services of health centers. So if a client is pregnant, we should not allow more entries in that line (for that client)- that row should be empty after the pregnancy field to ensure better data quality. The problems is that some grantees (staff) enter data by mistake and make the dataset messy. Is there a way to restrict entries in a cell based on the previous or other cells? Data validation? If i can do this my dataset will be much cleaner. Please let me know if you have any ideas.

    Best,
    MArvin

  13. #13
    Registered User
    Join Date
    07-24-2013
    Location
    new york
    MS-Off Ver
    Excel 2003
    Posts
    62

    Re: Nested if statatement + count

    ANyone Please! or should I open a new discussion?

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Nested count and total?
    By srwafu in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 11-02-2012, 09:24 AM
  2. [SOLVED] "IF" statatement help while using checkboxes
    By sourbeer in forum Excel General
    Replies: 9
    Last Post: 06-07-2012, 01:27 PM
  3. Nested AND or IF inside of count
    By wmatthai in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-26-2010, 03:48 PM
  4. Nested Count IF Function
    By LLori998 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-08-2008, 05:20 PM
  5. Nested count and vlookups
    By Chrisnelsonusa in forum Excel General
    Replies: 1
    Last Post: 06-06-2005, 03:05 PM

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