+ Reply to Thread
Results 1 to 17 of 17

How to count a column if it matches data from another column in seperate rows.

Hybrid View

Troisi How to count a column if it... 02-06-2009, 12:58 PM
Bedford_Excel Re: How to count a column if... 02-06-2009, 01:28 PM
DonkeyOte Re: How to count a column if... 02-06-2009, 02:12 PM
ChemistB Re: How to count a column if... 02-06-2009, 02:22 PM
DonkeyOte Re: How to count a column if... 02-06-2009, 02:30 PM
Troisi Re: How to count a column if... 02-06-2009, 02:34 PM
ChemistB Re: How to count a column if... 02-06-2009, 02:59 PM
Troisi Re: How to count a column if... 02-09-2009, 05:55 AM
DonkeyOte Re: How to count a column if... 02-09-2009, 05:56 AM
Troisi Re: How to count a column if... 02-09-2009, 06:03 AM
DonkeyOte Re: How to count a column if... 02-09-2009, 06:05 AM
Troisi Re: How to count a column if... 02-09-2009, 06:13 AM
DonkeyOte Re: How to count a column if... 02-09-2009, 06:30 AM
Troisi Re: How to count a column if... 02-09-2009, 07:29 AM
  1. #1
    Registered User
    Join Date
    02-06-2009
    Location
    luxembourg
    MS-Off Ver
    Excel 2002
    Posts
    8

    How to count a column if it matches data from another column in seperate rows.

    I have two columns with dates. Colum A has the date of the deadline of a document while column b has the day it was sent. Column X will display the difference if its a positive integer ( i.e. if the document has been sent after the deadline). Now i have another column Y which displays the month as an integer of when the document was actually received.

    Now i need a counter which will count the number of instances a positive integer is registered in column X according to the month in column Y. I have been trying everything but cant figure a simple way to do it. Im doing this so i can be able to see how many documents are sent after the deadline per month.

    Thanks a lot
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    02-03-2009
    Location
    MA, USA
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: How to count a column if it matches data from another column in seperate rows.

    The best way to do this is to create a count in a third column. Use a function sililar to: IF( A>B,1,0) If the sent date is more then the due date return a 1 if not then 0. Now you can sum the new column to find out how many times you had that event.

  3. #3
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: How to count a column if it matches data from another column in seperate rows.

    A few points re: your file

    I would change the formula in D such that:

    D2: =IF(N(C2)>B2,C2-B2,"")
    copy down
    I would change formula in E such that:

    E2: =IF(N(A2),MONTH(A2),"")
    copy down
    To get the count you can use a SUMPRODUCT... eg:

    H2: =SUMPRODUCT(--(E2:E500=G2),--(ISNUMBER(D2:D500)))
    where G2 holds month number
    I would however suggest you look into using Pivot Tables, see:
    http://peltiertech.com/Excel/Pivots/pivotstart.htm

    They are designed for this very type of task.

  4. #4
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: How to count a column if it matches data from another column in seperate rows.

    You can use a SUMPRODUCT for each month For Jan in your example
    =SUMPRODUCT(--($E$2:$E$35=1),--($D$2:$D$35>0),--(ISNUMBER($D$2:$D$35)))
    Does that work for you? As an aside, you wouldn't need the Month Column. Just change the formula to
    =SUMPRODUCT(--(MONTH($A$2:$A$35)=1),--($D$2:$D$35>0),--(ISNUMBER($D$2:$D$35)))
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  5. #5
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: How to count a column if it matches data from another column in seperate rows.

    ChemistB

    I would make two Points re: your formulae:

    1 - Given D is only numeric if > 0 you need not test both for ISNUMBER and > 0 as illustrated an ISNUMBER test shall suffice.

    2 - Re: using MONTH Column A -- this is risky if it's likely the range in use will contain blanks... given a blank equates to 0 and in date terms 0 is 00 Jan 1900 (ignoring 1904 date system) ... blanks when coerced with MONTH will return a value of 1 ... for this reason you should add an additional ISNUMBER test on the range.

  6. #6
    Registered User
    Join Date
    02-06-2009
    Location
    luxembourg
    MS-Off Ver
    Excel 2002
    Posts
    8

    Re: How to count a column if it matches data from another column in seperate rows.

    Ive gotten past the 1 problem for the month. That wasnt really a biggy. Im concerned with getting a count

  7. #7
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: How to count a column if it matches data from another column in seperate rows.

    Good Point D.O Thanks

  8. #8
    Registered User
    Join Date
    02-06-2009
    Location
    luxembourg
    MS-Off Ver
    Excel 2002
    Posts
    8

    Re: How to count a column if it matches data from another column in seperate rows.

    Yeah i use pivot tables. in this case though this is what i need. the data needs to be used in another table. lot of shitty stuff. but thanks everyone. will try everything out now

  9. #9
    Registered User
    Join Date
    02-06-2009
    Location
    luxembourg
    MS-Off Ver
    Excel 2002
    Posts
    8

    Re: How to count a column if it matches data from another column in seperate rows.

    What i need exactly is to get a count for D:D for all instances when E:E is = to g2 ( the month number) but i cant figure out the formula to do that correct.y :S

  10. #10
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: How to count a column if it matches data from another column in seperate rows.

    The formula provided does that.

    Post the file you are using presently.

  11. #11
    Registered User
    Join Date
    02-06-2009
    Location
    luxembourg
    MS-Off Ver
    Excel 2002
    Posts
    8

    Re: How to count a column if it matches data from another column in seperate rows.

    Its the same one i uploaded. I changed the formulas just as you said but it gives me 4.. for all months actually.

  12. #12
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: How to count a column if it matches data from another column in seperate rows.

    Really ??
    I guess I'll just have to do the work and upload the file.
    Attached Files Attached Files

  13. #13
    Registered User
    Join Date
    02-06-2009
    Location
    luxembourg
    MS-Off Ver
    Excel 2002
    Posts
    8

    Re: How to count a column if it matches data from another column in seperate rows.

    hmmm weird... but thanks a lot I honestly just copy and pasted. Would you mind explaining the formula a bit donkeyote maybe i can understand it better. not to bother you anytime soon

  14. #14
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: How to count a column if it matches data from another column in seperate rows.

    =SUMPRODUCT(--(E2:E500=G2),--(ISNUMBER(D2:D500)))

    For each cell in E2:E500... = G2 ... will return Boolean TRUE/FALSE ... the double unary -- will coerce the Boolean to it's integer equivalent (1/0 in native XL respectively)

    For each cell in D2:D500 ... ISNUMBER ... will equally return Boolean TRUE/FALSE which is also coerced.

    So you end up with 2 arrays (E & D) of 499 values consisting of either 1 or 0 and you sum the Products of those arrays... say:

    E2 = G2, D2 number
    E3 <> G2, D3 number

    For row 2: PRODUCT(1,1) => 1 [1 x 1]
    For row 3: PRODUCT(0,1) => 0 [0 x 1]

    Sum of those Products = 1 [1+0]
    Last edited by DonkeyOte; 02-09-2009 at 06:35 AM. Reason: incorrect cell reference in example

  15. #15
    Registered User
    Join Date
    02-06-2009
    Location
    luxembourg
    MS-Off Ver
    Excel 2002
    Posts
    8

    Re: How to count a column if it matches data from another column in seperate rows.

    thanks a lot perfect explanation

+ 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