+ Reply to Thread
Results 1 to 2 of 2

Thread: Changing COUNTIF formula

  1. #1
    Registered User
    Join Date
    10-16-2011
    Location
    Chicago
    MS-Off Ver
    Excel Mac 2011
    Posts
    1

    Changing COUNTIF formula

    I'm fairly new to Excel, although I understand all of the basic stuff very well.

    An employee who has since left us created a file for us using the following formula to count the number of occurrences of a specific sales item in our sales history per month:

    =COUNTIF('Feb 2011'!$J:$J,"*"&'Monthly Summary'!B5&"*")+COUNTIF('Feb 2011'!$J:$J,"*"&'Monthly Summary'!B5&" (2)"&"*")+(2*(COUNTIF('Feb 2011'!$J:$J,"*"&'Monthly Summary'!B5&" (3)"&"*")))

    I believe that I understand everything about this formula except, why is there a (2*(COUNTIF in the third string?

    Also: I want to basically copy this file but look at day-by-day sales of certain items instead of month-by-month.

    So I created a new file, copied all of the data in, renamed the tab "Monthly Summary". Then I created another tab and pasted the data from the original "Feb 2011" file. I renamed it Oct 1, cleared all of the February data out, and pasted in the sales data from Oct 1.

    The count formula is not working correctly though, the numbers it's giving me are way off. Is there anything else I need to think of changing, anything I'm missing that must be specific to the first file only?
    Last edited by saltyseathings; 10-16-2011 at 11:03 AM.

  2. #2
    Forum Moderator daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2007
    Posts
    10,056

    Re: Why multiple COUNTIFs ?

    I assume that figure in brackets is a count so assuming that Monthly Summary'!B5 contains the value "xxx" the first COUNTIF counts all entries which contain "xxx".....the second COUNTIF counts all entries that contain "xxx (2)" and the third counts those that contain "xxx (3)". Now the first one will, by definition, also count the latter two, so by multiplying the third by 2 you get a single count of "xxx" a double count of "xxx (2)" (one from 1st COUNTIF one from second) and a triple count of "xxx (3)" (one from 1st COUNTIF two from third)

    You can make it shorter with this version

    =SUM(COUNTIF('Feb 2011'!$J:$J,"*"&'Monthly Summary'!B5&{"*"," (2)*"," (3)*"})*{1,1,2})
    Audere est facere

+ 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.2.0