+ Reply to Thread
Results 1 to 16 of 16

Formula not working for sumproduct when only looking up 2 values

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

    Formula not working for sumproduct when only looking up 2 values

    Hi-

    I am trying to sum up column V, when for a specific date in column z, and only sum when the two names EEM, Merri1* are involved. I used the * because there are a couple of variations for MErri1 after the 1. The formula is not working. I believe it's the way I'm combining this
    Please Login or Register  to view this content.
    Full formula is below:

    Please Login or Register  to view this content.
    Thanks

  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,732

    Re: Formula not working for sumproduct when only looking up 2 values

    Try it like this:

    =SUMPRODUCT((MONTH('EZE DATA'!$Z$2:$Z$5000)=MONTH(H$7))*(('EZE DATA'!$K$2:$K$5000="EEM")+(ISNUMBER(SEARCH("MERRI1",'EZE DATA'!$K$2:$K$5000")))),'EZE DATA'!$V$2:$V$5000)

    Note the * is equivalent to AND, and the + is equivalent to OR for arrays.

    Hope this helps.

    Pete

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

    Re: Formula not working for sumproduct when only looking up 2 values

    This works. Thanks. What does Isnumber/search do?

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

    Re: Formula not working for sumproduct when only looking up 2 values

    The SEARCH function enables you to see if the string "Merri1" is contained anywhere within the cell it is looking at (similar to counting for "*Merri1*" with COUNTIF, but you can't use wildcards in this situation). If it is, then it returns a number, so ISNUMBER will return TRUE, but if it is not in the cell it will return an error, so ISNUMBER traps that and returns FALSE. Obviously, it looks at every cell in the range as one of the terms of the SP function.

    Hope this helps.

    If that takes care of your original question, please select Thread Tools from the menu above your first post and mark this thread as SOLVED.

    Also, you can directly thank those who have helped you by clicking on the small "star" icon located in the lower left corner of a post that you have found to be helpful (not just in this thread - for any post that has helped you). This also adds to the reputation of the poster (the small green bars in the poster's profile).

    Pete

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

    Re: Formula not working for sumproduct when only looking up 2 values

    Ok thanks. One more question. I have a similar issue with a countif formula I have trying to go off a certain month like above. Any ideas how to fix? Excel says I have too many arguments. I am trying to say count when z2:z500in eze data=month in trading stats tab h7 but disregard cross, and merri1*

    Please Login or Register  to view this content.

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

    Re: Formula not working for sumproduct when only looking up 2 values

    You can't manipulate the array if you are using COUNTIF/COUNTIFS (i.e. by comparing the month of that array), and you had a bracket missing anyway. You are looking in a different range for <>"Cross", so you can do it like this with SP:

    =SUMPRODUCT((MONTH('EZE DATA'!Z2:Z5000='Trading Statistics'!H7)*(NOT(ISNUMBER(SEARCH("MERRI1",'EZE DATA'!K2:K5000))))*('EZE DATA'!Y2:Y5000<>"CROSS"))

    or you could have (ISERROR(SEARCH( ... ))) for the middle term.

    Hope this helps.

    Pete

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

    Re: Formula not working for sumproduct when only looking up 2 values

    That makes sense, however I am not looking to sum. In column Z there is a date for every trade we have. I am simply trying to count the number of dates/trades in a certain month (trading stats h7). Is there something that I can manipulate like that? you said a countif will not work.

  8. #8
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Formula not working for sumproduct when only looking up 2 values

    sumproduct as pete has used it will sum ie count the number of times all three conditions are met
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

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

    Re: Formula not working for sumproduct when only looking up 2 values

    Did you try the formula? It COUNTS in this instance (SUMPRODUCT is flexible like that - it can be used for counting AND for summing)

    Pete

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

    Re: Formula not working for sumproduct when only looking up 2 values

    Here is attached sample. it returns a value of 4,956. It should be 150. Maybe the dates are in an odd format, not sure. I would assume I can use a similar format once fixed to come up with avg price in c17 using sumproduct instead of avgifs

    thanks
    Attached Files Attached Files

  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,732

    Re: Formula not working for sumproduct when only looking up 2 values

    You should be using this formula:

    =SUMPRODUCT((MONTH('EZE DATA'!Z2:Z5000)=MONTH('Trading Statistics'!C7))*(NOT(ISNUMBER(SEARCH("MERRI1",'EZE DATA'!K2:K5000))))*('EZE DATA'!Y2:Y5000<>"CROSS"))

    and you need to convert the "dates" in column Z to proper dates. To do this quickly, highlight column Z, then click on Data | Text-to-Columns, then click Fixed width | Next | Next and in the third panel select MDY from the Date drop-down and click OK.

    You should get an answer of 152 with these modifications.

    Hope this helps.

    Pete

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

    Re: Formula not working for sumproduct when only looking up 2 values

    Thank you so much for your help. That worked. My last question, is how can I use an averagif (or some avg formula) while also incorporating months like above?

  13. #13
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Formula not working for sumproduct when only looking up 2 values

    You can stick with COUNTIFS and use this version for a count

    =COUNTIFS('EZE DATA'!Z2:Z5000,">="&C7,'EZE DATA'!Z2:Z5000,"<"&EOMONTH(C7,0)+1,'EZE DATA'!K2:K5000,"<>MERRI1*",'EZE DATA'!Y2:Y5000,"<>CROSS")

    That gives me 152 too - once dates are fixed

    As you can see that uses two criteria for the dates with a start and end. You can use exactly the same setup with AVERAGEIFS function instead of COUNTIFS
    Audere est facere

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

    Re: Formula not working for sumproduct when only looking up 2 values

    I receive an excel error. Too few arguments for this function. Any ideas? The Countifs worked though.
    Please Login or Register  to view this content.

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

    Re: Formula not working for sumproduct when only looking up 2 values

    just wanted to follow up to see if anyone could figure out my issue with the averageifs?

    Thanks

  16. #16
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Formula not working for sumproduct when only looking up 2 values

    Which range are you trying to average? - that has to go at the start of the formula, e.g. to average column V where all conditions are met in other rows use this version

    =AVERAGEIFS('EZE DATA'!V2:V5000,'EZE DATA'!Z2:Z5000,">="&C7,'EZE DATA'!Z2:Z5000,"<"&EOMONTH(C7,0)+1,'EZE DATA'!K2:K5000,"<>MERRI1*",'EZE DATA'!Y2:Y5000,"<>CROSS")

+ 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. [SOLVED] SUMPRODUCT Formula is not working and I cant see what is wrong with it
    By necht_angel in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 11-19-2013, 10:31 AM
  2. Sumproduct formula not working
    By cartica in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 08-20-2013, 11:19 AM
  3. SUMPRODUCT formula not working
    By KINNEY0201 in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 09-28-2010, 12:26 PM
  4. SumProduct Formula not working
    By jfwidt in forum Excel General
    Replies: 6
    Last Post: 02-03-2010, 05:18 PM
  5. Sumproduct not working when summing values between two numbers
    By FlamencoKid in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 09-13-2005, 01:05 PM

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