+ Reply to Thread
Results 1 to 5 of 5

Thread: Problem with 2 conditions in order to count

  1. #1
    Registered User
    Join Date
    03-30-2010
    Location
    Minneapolis, MN
    MS-Off Ver
    Excel 2003
    Posts
    2

    Question Problem with 2 conditions in order to count

    Here is my problem. I need to look at D2:D607 and see if equals DTW.If it does, then I only want to count it if cells H2:H607 are nonblank. I've tried a few ways but they have all had errors with the structure. Please help me get on the right track. Thank you so much in advance for any help you can provide me.
    Last edited by NBVC; 03-30-2010 at 12:57 PM.

  2. #2
    Forum Moderator Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2007
    Posts
    5,953

    Re: Problem with 2 conditions in order to count

    Hi Koncurn, welcome to the forum.

    Try this formula:

    =SUMPRODUCT(--(D2:D607="DTW"),--(H2:H607<>""))

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

    Re: Problem with 2 conditions in order to count

    Try:

    =Sumproduct(--(D2:D607="DTW"),--(H2:H607<>""))
    Microsoft MVP - Excel

    Where there is a will there are many ways. Pick One!


    Please read the Forum Rules

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

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

    Preferred Charities: Lupus Canada and Sick Kids Foundation.
    Feel Free to Donate if you want to, for the assistance you received today.

  4. #4
    Registered User
    Join Date
    03-30-2010
    Location
    Minneapolis, MN
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Problem with 2 conditions in order to count

    Thank you so much as this worked like a charm. Could you explain what the--in the equation means so that I can learn and help myself more? Thanks again.

  5. #5
    Forum Moderator Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2007
    Posts
    5,953

    Re: Problem with 2 conditions in order to count

    The two dashes are called unary operators (double unary in this case). It serves to coerce (convert) the TRUE/FALSE values returned by each condition of the SUMPRODUCT into 1's and 0's in order to perform mathematical calculations on them.

    For example, in your formula you'd get something like:

    =SUMPRODUCT(--(D2:D607="DTW"),--(H2:H607<>""))
    =SUMPRODUCT(--({TRUE;TRUE;FALSE;FALSE...}),--({TRUE;FALSE;FALSE;TRUE;...}))
    =SUMPRODUCT({1;1;0;0;...},{1;0;0;1;...})
    =18

    Hope that makes sense on a basic level. There's many threads discussing/arguing SUMPRODUCT and using double-unary operators vs. multiplication, e.g. (D2:D607="DTW")*(H2:H607<>""), but you can usually use both interchangeably.

+ 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.2.0