+ Reply to Thread
Results 1 to 5 of 5

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 Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885

    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 Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Problem with 2 conditions in order to count

    Try:

    =Sumproduct(--(D2:D607="DTW"),--(H2:H607<>""))
    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
    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 Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885

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