+ Reply to Thread
Results 1 to 10 of 10

If then type formula to extract/count items in a column

  1. #1
    Registered User
    Join Date
    09-04-2012
    Location
    Tyler, TX
    MS-Off Ver
    Excel 2010
    Posts
    11

    Question If then type formula to extract/count items in a column

    Good morning all -

    I am working on a spreadsheet and have extracted data from an ODBC database and need your assistance with a formula.

    I have in column L, certain codes as they apply to public safety responses. Codes such as 5150, 01A01, 17A02, 25A01, 04B01, etc.

    I need to count these codes in the following manor: All 5150 & 25A01 & 25A02 together, All remaining codes with 'A', and then all 'B' codes together.

    Can you please help and tell me the best way to accomplish this? My knowledge is in Crystal and not so much Excel. Thank you in advance.

  2. #2
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: If then type formula to extract/count items in a column

    Does this get you what you want?

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    HTH
    Regards, Jeff

  3. #3
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: If then type formula to extract/count items in a column

    Try:

    =SUM(COUNTIF(L:L,{"5150","25A01","25A02"}))

    and

    =COUNTIF(L:L,"*A*")-SUM(COUNTIF(L:L,{"25A01","25A02"})

    =COUNTIF(L:L,"*B*")
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  4. #4
    Registered User
    Join Date
    09-04-2012
    Location
    Tyler, TX
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: If then type formula to extract/count items in a column

    Will the Alpha statement above in your second formula exclude the Alpha calls it already counted in the 5150 formula that you posted first?

    I don't want it to count the 25A01 & 25A02 again in the 'A' count.

  5. #5
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: If then type formula to extract/count items in a column

    Have you seen my second formula:

    =COUNTIF(L:L,"*A*")-SUM(COUNTIF(L:L,{"25A01","25A02"})

    this subtract the counts of those 2 from the other A's

  6. #6
    Registered User
    Join Date
    09-04-2012
    Location
    Tyler, TX
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: If then type formula to extract/count items in a column

    Quote Originally Posted by NBVC View Post
    Try:

    =SUM(COUNTIF(L:L,{"5150","25A01","25A02"}))

    and

    =COUNTIF(L:L,"*A*")-SUM(COUNTIF(L:L,{"25A01","25A02"})

    =COUNTIF(L:L,"*B*")
    Thank you NBVC, that worked perfectly! I appreciate the quick responses.

  7. #7
    Registered User
    Join Date
    09-04-2012
    Location
    Tyler, TX
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: If then type formula to extract/count items in a column

    Quote Originally Posted by NBVC View Post
    Have you seen my second formula:

    =COUNTIF(L:L,"*A*")-SUM(COUNTIF(L:L,{"25A01","25A02"})

    this subtract the counts of those 2 from the other A's
    Yes, sorry...you had replied to my OP when I was composing my question to 'jeffreybrown'. Thanks again!

  8. #8
    Registered User
    Join Date
    09-04-2012
    Location
    Tyler, TX
    MS-Off Ver
    Excel 2010
    Posts
    11

    Question Re: If then type formula to extract/count items in a column

    One additional question related to my OP:

    In column M I have whether the patient was transported or not (1 for yes 0 for no), what formula could I use in conjunction with what you guys have already provided to count the codes in column L if there is a '1' in column M, indicating a transport?

    Thank you!

  9. #9
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: If then type formula to extract/count items in a column

    Change the COUNTIF to COUNTIFS and use multiple criteria.

    Try:

    =SUM(COUNTIFS(L:L,{"5150","25A01","25A02"},M:M,1))

    and

    =COUNTIFS(L:L,"*A*",M:M,1)-SUM(COUNTIFS(L:L,{"25A01","25A02"},M:M,1)

    =COUNTIFS(L:L,"*B*",M:M,1)

  10. #10
    Registered User
    Join Date
    09-04-2012
    Location
    Tyler, TX
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: If then type formula to extract/count items in a column

    That worked perfectly! Thank you again for the quick reply. You are most helpful!
    Last edited by Cutter; 09-04-2012 at 01:41 PM. Reason: Removed whole post quote

+ 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.6.0 RC 1