+ Reply to Thread
Results 1 to 5 of 5

Counting entries w/ AND condition

  1. #1
    Registered User
    Join Date
    12-16-2004
    Posts
    15

    Counting entries w/ AND condition

    I have a list of data with 3 columns:

    Col A: Dates
    Col B: Prices
    Col C: Costs

    I want to create a table that counts the number of times that the price is more than a certain value and the cost is less than a certain other value in the same month (regardless of the year and day).

    For example:

    On 2/20/2004 the price was 100 and the cost was 50
    On 2/14/2005 the price was 75 and the cost was 75
    On 2/18/2005 the price was 50 and the cost was 40

    I want to count the number of times that the price is above 60 AND the cost is below 70, given that the month is February. I need a formula for the above data that will return 2. The formula must lookup the month from Col A to do the search.

    Any ideas?

  2. #2
    Registered User
    Join Date
    07-01-2004
    Location
    Kent, UK
    Posts
    74
    From your sample data the answer should be 1 as only the data from 20/2/2004 meets both criteria.

    The following formula should give you what you need though:

    =SUMPRODUCT((MONTH(D2:D25)=2)*(E2:E25>60)*(F2:F25<70))

    This will count the number of occasions where month = february (2), Price >60 and cost <70 for data in rows 2-25 (expand as required).
    To sum for other months simply change the Month(D2:D25)= to 1-12 for each month.

  3. #3
    Registered User
    Join Date
    12-16-2004
    Posts
    15
    Thanks, Alex. My sample data should indeed return 1, my mistake. Your formula works. My next question is a little more complicated:

    I don't really care that there was 1 time in Feb. when both conditions were met--I really just need to know how many times the condidions are met in the same month. So if it was 1 for Feb. and 3 for Mar. and 5 for Apr., I need a formula to return 9. Is there any way to do this? I know I could have 12 of your formula and sum, but is there any way to do this all in 1 formula? I was thinking that some use of Countif() might be appropriate, but I'm not sure if Countif() can match the months in the criteria variable.

  4. #4
    Registered User
    Join Date
    07-01-2004
    Location
    Kent, UK
    Posts
    74
    That one exceeds my limited brainpower at the moment - will have a think!

  5. #5
    Forum Expert
    Join Date
    12-24-2004
    Location
    Sweden
    Posts
    1,256
    I might be missing something but Y not just use:
    =SUMPRODUCT((B2:B25>60)*(C2:C25<70)) ?

    Ola Sandström

+ 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