+ Reply to Thread
Results 1 to 5 of 5

Counting a sample (rows in a column) based on two criteria

  1. #1
    Registered User
    Join Date
    05-02-2013
    Location
    Madrid, Spain
    MS-Off Ver
    Excel 2011, Mac
    Posts
    19

    Counting a sample (rows in a column) based on two criteria

    Hi guys, here is my question..

    Imagine you have two columns: One with values a, b, c or /; and the other with values ranging from 69 to 84 (these are short for years).
    I have attached a sheet to make it more clear.

    What I need is to count how many values a, b and c I have in each year.

    What I have done so far is filtered the sheet, and then used a count function for each combination of (a,b,c) with (69-84).
    This works fine, but takes a lot of time, so I wanted to see if there is a shortcut.

    Thx
    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: Counting a sample (rows in a column) based on two criteria

    hi Lija, welcome to the forum. so what should the answer be? try this:
    =SUMPRODUCT((TRIM(B4:B496)<>"/")*(YEAR(C4:C496)>=1969)*(YEAR(C4:C496)<=1984))

    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
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Counting a sample (rows in a column) based on two criteria

    You need a pivot table.
    Also a 3rd column to extract the year from your dates in column C.
    You only had the dates in column C custom formatted to show just yy, but the actual value of the cells is still the whole date.


    Workbook29.xlsx

  4. #4
    Registered User
    Join Date
    05-02-2013
    Location
    Madrid, Spain
    MS-Off Ver
    Excel 2011, Mac
    Posts
    19

    Re: Counting a sample (rows in a column) based on two criteria

    Hi benishiryo,

    The answer should be a count of how many a, b and c I have in each year.

    For example
    3 a in 79
    4 a in 80
    5 b in 83
    18 c in 82

    and so on..

  5. #5
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Counting a sample (rows in a column) based on two criteria

    yep i agree a pivot table is easiest with a 3rd row for year see attached
    Attached Files Attached Files
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

+ 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