+ Reply to Thread
Results 1 to 16 of 16

Sumproduct based on two conditions of 1 one column

  1. #1
    Forum Contributor
    Join Date
    01-17-2011
    Location
    amsterdam, Netherlands
    MS-Off Ver
    Excel 2007
    Posts
    189

    Sumproduct based on two conditions of 1 one column

    H

    What I am trying count is:

    How many dates have not been received at 16 July (cell J2)?

    - For this we have to look at all trades smaller or same as 16 July so <=J2 (in column H)
    - Of these cells only the cells which have an value "yes" in column G
    - How many of these cells have a date above 16 July or an empty date in column F
    This last part is the only part I do not know how to solve it.

    See attached Excel File

    I want to do it with sumproduct and not with countifs , due to other restrictions

    I have tries option like:

    SUMPRODUCT((H2:H75<=J2)*(G2:G75="yes")*(F2:FH275>J2&" "))
    SUMPRODUCT((H2:H75<=J2)*(G2:G75="yes")*(F2:F75<J2&F2:F75=" "))


    Hope someone can help me
    Attached Files Attached Files
    Last edited by keis386; 07-31-2012 at 10:23 AM.

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,791

    Re: Sumproduct based on two conditions of 1 one column

    I think this is what you need:

    =SUMPRODUCT((H2:H75<=J2)*(G2:G75="yes")*(F2:F75>J2)*(F2:F75<>""))

    Hope this helps.

    Pete

    ---------- Post added at 04:05 PM ---------- Previous post was at 04:04 PM ----------

    I think this is what you need:

    =SUMPRODUCT((H2:H75<=J2)*(G2:G75="yes")*(F2:F75>J2)*(F2:F75<>""))

    Hope this helps.

    Pete

  3. #3
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Sumproduct based on two conditions of 1 one column

    Hi

    Did you try?

    =SUMPRODUCT((H2:H75<=J2)*(G2:G75="yes")*(F2:F75>J2)*(F2:F75<>""))


    Edit! Pete:This time, you were faster.
    Last edited by Fotis1991; 07-30-2012 at 11:07 AM. Reason: Edit!
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

  4. #4
    Forum Contributor
    Join Date
    01-17-2011
    Location
    amsterdam, Netherlands
    MS-Off Ver
    Excel 2007
    Posts
    189

    Re: Sumproduct based on two conditions of 1 one column

    Works excellent thanks, I thought I tried that option already!

  5. #5
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,791

    Re: Sumproduct based on two conditions of 1 one column

    Quote Originally Posted by Fotis1991 View Post
    Edit! Pete:This time, you were faster.
    Yes, but I got the "you cannot post within 30 seconds - try again in 15 seconds" message, so I ended up double-posting !!

    Pete

  6. #6
    Banned User!
    Join Date
    10-14-2006
    Posts
    1,211

    Re: Sumproduct based on two conditions of 1 one column

    Quote Originally Posted by Pete_UK View Post
    I think this is what you need:

    =SUMPRODUCT((H2:H75<=J2)*(G2:G75="yes")*(F2:F75>J2)*(F2:F75<>""))

    Hope this helps.

    Pete

    ---------- Post added at 04:05 PM ---------- Previous post was at 04:04 PM ----------

    I think this is what you need:

    =SUMPRODUCT((H2:H75<=J2)*(G2:G75="yes")*(F2:F75>J2)*(F2:F75<>""))

    Hope this helps.

    Pete
    you no need to include the last piece (F2:F75<>"") , when you evaluate (F2:F75>J2)
    So the formula can be shorten

    =SUMPRODUCT((H2:H75<=J2)*(G2:G75="yes")*(F2:F75>J2))

  7. #7
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,791

    Re: Sumproduct based on two conditions of 1 one column

    Hi Mama,

    not seen you posting for ages - I remember you from the News Group days. Hope you are well.

    Pete

  8. #8
    Forum Contributor
    Join Date
    01-17-2011
    Location
    amsterdam, Netherlands
    MS-Off Ver
    Excel 2007
    Posts
    189

    Re: Sumproduct based on two conditions of 1 one column

    Hi,

    If I change the date in cell J2 to 21 July, it should give an number, but everything after 20 July turns out to 0.
    How can I change that. There are still empty cells in column F, so the formula should count these (only the empty cells that also satisfy the other conditions).

  9. #9
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Sumproduct based on two conditions of 1 one column

    Hi

    One reason, is


    =SUMPRODUCT((H2:H75<=J2)*(G2:G75="yes")*(F2:F75>J2)*(F2:F75<>""))

    In column F, biggest date is 21/07.....

  10. #10
    Forum Contributor
    Join Date
    01-17-2011
    Location
    amsterdam, Netherlands
    MS-Off Ver
    Excel 2007
    Posts
    189

    Re: Sumproduct based on two conditions of 1 one column

    Yes I get this, but the whole problem was that column F has two conditions: is bigger than J2 or cell is empty.

    =SUMPRODUCT((H2:H75<=J2)*(G2:G75="yes")*(F2:F75>J2)*(F2:F75<>""))

  11. #11
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,791

    Re: Sumproduct based on two conditions of 1 one column

    If you want OR, then you can do it this way:

    =SUMPRODUCT((H2:H75<=J2)*(G2:G75="yes")*((F2:F75>J2)+(F2:F75<>"")))

    Hope this helps.

    Pete

  12. #12
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Sumproduct based on two conditions of 1 one column

    Quote Originally Posted by keis386 View Post
    Yes I get this, but the whole problem was that column F has two conditions: is bigger than J2 or cell is empty.

    =SUMPRODUCT((H2:H75<=J2)*(G2:G75="yes")*(F2:F75>J2)*(F2:F75<>""))
    This is AND. Not OR.

    Try

    =SUMPRODUCT((H2:H75<=J2)*(G2:G75="yes")*(F2:F75>J2))+SUMPRODUCT((H2:H75<=J2)*(G2:G75="yes")*(F2:F75=""))

  13. #13
    Forum Contributor
    Join Date
    01-17-2011
    Location
    amsterdam, Netherlands
    MS-Off Ver
    Excel 2007
    Posts
    189

    Re: Sumproduct based on two conditions of 1 one column

    This is really excellent, why did I not think about this myself!

    I am sorry but I have still one minor question:
    If I add an value in column H and G the formula automatic adds a cell, because it is a table.
    But for column F the newest cell is mostly empty how can I make sure that the formula also adds one cell here? Like:

    =SUMPRODUCT((H2:H75<=J2)*(G2:G75="yes")*(F2:F75>J2))+SUMPRODUCT((H2:H75<=J2)*(G2:G75="yes")*(F2:F75= ""))
    So if I add a cell new formula will add a cell --> Should be like:
    =SUMPRODUCT((H2:H76<=J2)*(G2:G76="yes")*(F2:F76>J2))+SUMPRODUCT((H2:H76<=J2)*(G2:G76="yes")*(F2:F76= ""))

  14. #14
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Sumproduct based on two conditions of 1 one column

    One way could be this.

    =SUMPRODUCT((H2:H1175<=J2)*(G2:G1175="yes")*(F2:F1175>J2)*(G2:G1175<>""))+SUMPRODUCT((H2:H1175<=J2)*(G2:G1175="yes")*(F2:F1175= "")*(G2:G1175<>""))

    Replace the 1175 row, with any row number you want..

  15. #15
    Forum Contributor
    Join Date
    01-17-2011
    Location
    amsterdam, Netherlands
    MS-Off Ver
    Excel 2007
    Posts
    189

    Re: Sumproduct based on two conditions of 1 one column

    Thanks I appriciate this a lot!!

  16. #16
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Sumproduct based on two conditions of 1 one column

    You are welcome!

    I am happy that my suggestions work for you!

+ 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