+ Reply to Thread
Results 1 to 5 of 5

Adding multiple COUNTIFS issue

  1. #1
    Registered User
    Join Date
    09-08-2009
    Location
    Hawaii
    MS-Off Ver
    Excel 2013
    Posts
    68

    Adding multiple COUNTIFS issue

    I'm trying to build a schedule and I'm running into problems. On rows 37 (and eventually 38 once I nail this formula down) I am attempting to calculate the total number of D shifts and D* shifts based on the duty position in column B. Both D and D* should only count if the duty shift is a AN, AFN, LPN, CIV LPN, or CIV RN. I have what I thought was a solid formula when I only enter D*. This gives me the correct total. However, once I enter just a D, the number adds two more than needed.

    Where am I going wrong in formula in row 37? Please teach me to fish.

    Please Login or Register  to view this content.
    Thanks in advance!
    Attached Files Attached Files

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

    Re: Adding multiple COUNTIFS issue

    hi purdue7997. you should probably give us a bit more data & tell us which cell is wrong, why so & what should be the right answer. it seems like you already know that you should use "D*", but also included "D"? "D*" will count both cells E13:E14. "D" will count E13. hence the double counting & resulting in 3. and if you know how to use the curly brackets, you can do this in E37:
    =SUM(COUNTIFS($B$6:$B$35,{"AN","AFN","LPN","CIV LPN","CIV RN"},E6:E35,"D*"))

    and since you want to copy it down, you should also fix E6:E35 & include column C as a criteria:
    =SUM(COUNTIFS($B$6:$B$35,{"AN","AFN","LPN","CIV LPN","CIV RN"},E$6:E$35,"D*",$C$6:$C$35,LEFT($C37)))

    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

  3. #3
    Registered User
    Join Date
    08-22-2012
    Location
    Zagreb, Croatia
    MS-Off Ver
    Excel 2003
    Posts
    61

    Re: Adding multiple COUNTIFS issue

    Hi,
    I put solution in 40th row of your file. It is formula (for column E):
    Please Login or Register  to view this content.
    Note, that this formula is without array notification, because of using SUMPRODUCT function.

    Regards,
    Attached Files Attached Files
    If a post helps press star sign 4 my reputation

  4. #4
    Registered User
    Join Date
    09-08-2009
    Location
    Hawaii
    MS-Off Ver
    Excel 2013
    Posts
    68

    Re: Adding multiple COUNTIFS issue

    That code is much shorter and manageable than I originally came up with. It works for what I'm after. Thanks a bunch! I tried giving you rep but it seems I gave you some last time and need to spread more to others first. Thanks!

  5. #5
    Forum Contributor Portuga's Avatar
    Join Date
    02-20-2004
    Location
    Portugal
    MS-Off Ver
    365
    Posts
    852

    Re: Adding multiple COUNTIFS issue

    Glad you found a solution.

    This is just an explanation of why it was doing it.

    The issue relates to the fact that you are considering "D*" in itself as a unique value, while used in a formula like that, works as a wildcard, counting all cells with a D on it. So if you put "DCN", it will count that also, since it has a D on it.

    In countifs for this to work, you would have to change it to "D~*"
    If you found the solution to your question. Mark the thread as "Solved"
    Thank everyone that helped you with a valid solution by clicking on their

    There is no such thing as a problem, only a temporary lack of a solution

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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