+ Reply to Thread
Results 1 to 21 of 21

Countif inquiry

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    07-21-2013
    Location
    washington dc
    MS-Off Ver
    365 MSO
    Posts
    473

    Countif inquiry

    HI-

    What would my countif formula be if I want to count the unique number of days for below. In column "A" I have dates, and in column "B" i have an identifier "wtd". So I want it to return the number 3. I am looking for the unique number of days associated with "wtd".

    08/13/2013
    08/13/2013
    08/13/2013
    08/13/2013
    08/13/2013
    08/13/2013
    08/13/2013
    08/13/2013
    08/14/2013
    08/14/2013
    08/14/2013
    08/14/2013
    08/14/2013
    08/14/2013
    08/15/2013
    08/15/2013
    08/15/2013
    08/15/2013
    08/15/2013
    08/15/2013
    08/15/2013
    08/16/2013
    08/16/2013
    08/16/2013
    08/16/2013
    08/16/2013
    08/16/2013
    08/19/2013 WTD
    08/19/2013 WTD
    08/19/2013 WTD
    08/19/2013 WTD
    08/19/2013 WTD
    08/20/2013 WTD
    08/20/2013 WTD
    08/20/2013 WTD
    08/21/2013 WTD
    08/21/2013 WTD
    08/21/2013 WTD

  2. #2
    Forum Contributor
    Join Date
    08-02-2013
    Location
    Wageningen, The Netherlands
    MS-Off Ver
    365
    Posts
    495

    Re: Countif inquiry

    Here's a formula to find the number of unique values, but i can't find out how to count only those with WTD next to it. Maybe someone else can add this?

    =SUM(IF(INTERVAL(MATCH(A1:A100,A1:A100,0),MATCH(A1:A100,A1:A100,0))>0,1))
    When I say semicolon, u say comma!

  3. #3
    Forum Contributor
    Join Date
    08-02-2013
    Location
    Wageningen, The Netherlands
    MS-Off Ver
    365
    Posts
    495

    Re: Countif inquiry

    Quote Originally Posted by L-Drr View Post
    Here's a formula to find the number of unique values, but i can't find out how to count only those with WTD next to it. Maybe someone else can add this?

    =SUM(IF(INTERVAL(MATCH(A1:A100,A1:A100,0),MATCH(A1:A100,A1:A100,0))>0,1))
    Anyway cartica, if you (or someone else) can somehow combine this formula with a LOOKUP (or something like that), the problem should be solved. Unfortunately I don't know how

  4. #4
    Forum Contributor
    Join Date
    08-02-2013
    Location
    Wageningen, The Netherlands
    MS-Off Ver
    365
    Posts
    495

    Re: Countif inquiry

    Hold up I did find out!

    =SUM(LOOKUP("WTD";B1:B100,A1:A100)*IF(INTERVAL(MATCH(A1:A100,A1:A100,0),MATCH(A1:A100,A1:A100,0))>0,1))

  5. #5
    Forum Contributor
    Join Date
    07-21-2013
    Location
    washington dc
    MS-Off Ver
    365 MSO
    Posts
    473

    Re: Countif inquiry

    That does not work for me. See formula below. I am using multiple tabs. G= column "wtd", and B= column Date Eze data is just a tab name

    =SUM(LOOKUP('EZE DATA'!G2:G5000,"WTD",'EZE DATA'!B2:B5000)*IF(interval(MATCH('EZE DATA'!B2:B5000,'EZE DATA'!B2:B5000,0),MATCH('EZE DATA'!B2:B5000,'EZE DATA'!B2:B5000,0))>0,1))

  6. #6
    Forum Contributor
    Join Date
    08-02-2013
    Location
    Wageningen, The Netherlands
    MS-Off Ver
    365
    Posts
    495

    Re: Countif inquiry

    Oh, no, I see it's not working for me either

  7. #7
    Registered User
    Join Date
    08-21-2013
    Location
    Maryland
    MS-Off Ver
    Excel 2010
    Posts
    17

    Re: Countif inquiry

    I also have a countif question..... If I want to count how many markets there are based on whether or not they are in a specific region or assigned to a specific portfolio how would I go about doing that? I've attached a spreadsheet as an example with ???? marks where I need the help.
    Attached Files Attached Files

  8. #8
    Forum Contributor
    Join Date
    08-02-2013
    Location
    Wageningen, The Netherlands
    MS-Off Ver
    365
    Posts
    495

    Re: Countif inquiry

    You did switch 2 arguments in the lookup, is that un purpose?
    What exactly is not working? Are you getting an error as the wrong result?
    Maybe I did something wrong in my translation from Dutch to English (both semantics and syntax are different)

  9. #9
    Forum Contributor
    Join Date
    08-02-2013
    Location
    Wageningen, The Netherlands
    MS-Off Ver
    365
    Posts
    495

    Re: Countif inquiry

    djreddy
    Forum rule number 2 (http://www.excelforum.com/forum-rule...rum-rules.html) states that you must start your own thread to ask your questions, do not use someone else's thread for that.

  10. #10
    Registered User
    Join Date
    08-21-2013
    Location
    Maryland
    MS-Off Ver
    Excel 2010
    Posts
    17

    Re: Countif inquiry

    My apologies!

  11. #11
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Countif inquiry

    This is an array formula, adjust the range as needed:

    =COUNT(1/FREQUENCY(IF(B1:B100="WTD",A1:A100),A1:A100))

    ...confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer. Press F2 on that cell and try again.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  12. #12
    Registered User
    Join Date
    08-21-2013
    Location
    los angeles, USA
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Countif inquiry

    You can also use =SUMPRODUCT((A1:A38>0)*(A1:B38="wtd"))

  13. #13
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Countif inquiry

    Quote Originally Posted by tdewale View Post
    You can also use =SUMPRODUCT((A1:A38>0)*(A1:B38="wtd"))
    No, this counts EVERY value in column A that has WTD in column B, an answer of 11 based on the sample data. The answer desired is 3, the count of UNIQUE values that have WTD in column B.

    Quote Originally Posted by cartica View Post
    So I want it to return the number 3. I am looking for the unique number of days associated with "wtd".

  14. #14
    Forum Contributor
    Join Date
    07-21-2013
    Location
    washington dc
    MS-Off Ver
    365 MSO
    Posts
    473

    Re: Countif inquiry

    JBEAUCAIRE-

    The formula isn't working. It's returning a zero. Below is what I am using. The dates maybe text, not sure if that is a probelm. I am exporting the data from a system. I have read forum rules, but still can't figure out how to post my spreadsheet withought posting a new thread?

    =COUNT(1/FREQUENCY(IF('EZE DATA'!G2:G5000="WTD",'EZE DATA'!B2:B5000),'EZE DATA'!B2:B5000))

  15. #15
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Countif inquiry

    It will return zero if you do not follow the instructions given to activate the array.

    Enter the formula confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer. Press F2 on that cell and try again.


    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic

  16. #16
    Forum Contributor
    Join Date
    07-21-2013
    Location
    washington dc
    MS-Off Ver
    365 MSO
    Posts
    473

    Re: Countif inquiry

    excel question.xlsx


    JBeaucaire- see my attachment. I am using the brackets, but still not returning 3. Not sure what I am doing wrong.

    Thanks

  17. #17
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Countif inquiry

    The data in your column B "looks" like dates, but it's text. You need to convert those strings into dates.

    1) Highlight column B
    2) Select Data > Text To Columns > Delimited > Next > Next
    3) On the third screen, click on DATE > DMY and click OK.

    Now the formula will work.

  18. #18
    Forum Contributor
    Join Date
    07-21-2013
    Location
    washington dc
    MS-Off Ver
    365 MSO
    Posts
    473

    Re: Countif inquiry

    is there another option? I importing all data on a daily basis, so I don't want to have to manually reformat the dates on a daily basis. Can't you add a 0 to formula. I know that sometimes works?

    Thanks

  19. #19
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Countif inquiry

    I suppose you could record a macro of you doing the steps I outlined. Then you would have it done by just running the macro, fewer clicks.

  20. #20
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Countif inquiry

    Try this array formula, a similar function for TEXT.

    =SUM(IF('EZE DATA'!$G$2:$G$559="WTD", 1/(COUNTIFS('EZE DATA'!$G$2:$G$559, "WTD", 'EZE DATA'!$B$2:$B$559, 'EZE DATA'!$B$2:$B$559)), 0))

  21. #21
    Forum Contributor
    Join Date
    07-21-2013
    Location
    washington dc
    MS-Off Ver
    365 MSO
    Posts
    473

    Re: Countif inquiry

    the array formula didn't work. If i change column like you stated previously that works. If I were to add a macro to do the data text like you suggested, what would be the code?

    Thanks

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Scheduling Inquiry
    By gum605 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-17-2012, 05:55 PM
  2. [SOLVED] IF Statement Inquiry
    By Opus1 in forum Excel General
    Replies: 16
    Last Post: 03-30-2012, 09:59 AM
  3. IF Formula Inquiry
    By Mrgbolee in forum Excel General
    Replies: 3
    Last Post: 10-22-2010, 08:26 PM
  4. Formula Inquiry
    By lilsnoop in forum Excel General
    Replies: 5
    Last Post: 04-02-2007, 09:59 PM
  5. VLOOKUP inquiry
    By Duley in forum Excel General
    Replies: 2
    Last Post: 06-23-2006, 10:37 AM

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