+ Reply to Thread
Results 1 to 8 of 8

Additional criteria for 'sumproduct' formula

  1. #1
    Registered User
    Join Date
    01-28-2009
    Location
    Ottawa, Canada
    MS-Off Ver
    Excel 2003
    Posts
    4

    Additional criteria for 'sumproduct' formula

    Hello, Thank you in advance for your help. I belive this is probably a simple question for someone with expert-level Excel knowledge, so thanks for taking the time to help.

    I have an Excel workbook that is doing several calculations. Right now I have 2 tabs within the book that I am focusing on fixing a formula.

    TabA is a summarative sheet, in that I have the formula used frequently:
    =SUMPRODUCT((Comparison!F$1:F$17889="X")*(Comparison!$A$1:$A$17889=$A7)

    Comparison! is the 2nd tab, which lists many thousands of rows of assets held in different cities
    Col A = shows the names of the city (in both tabs - TabA it shows it in the summarative table, and in Comparison! it shows it as the city name for each asset)
    Col B = has an X if the data has changed since our last report (based on another spreadsheet, but that is unimportant to the question)

    You can see in my formula, there are 17889 rows of assets in the tab. However, there is actually about 20000, but I specifically put 17889 because i need to differntiate between old assets and new ones (rows 1-17889 are old assets, rows 17890 to 20000 are new assets. New assets are always listed at the bottom). So we have 17889 old assets, and then the rest are new. I know this because I manually looked at the spreadsheet. Each time I run the report, I have to manually do this, and then do a formula replace, replacing the 17889 with whatever the new number is of "old assets", so that I exclude new assets.

    However, this is where I'd like to fix the formula, so I can do this without manually having to do anything, or ever having to change the formula. And the way I could do this is to add in a criteria that: if col B = the letter "X", then it should not count.

    So ideally the formaul would end up being something like:
    =SUMPRODUCT((Comparison!F$1:F$20000="X")*(Comparison!$A$1:$A$20000=$A7)-when B$1:B$200000="X"

    But of course the "-when" would be replaced by something else. And also, with order of operations issues, I'm sure its not even written like this anyways.

    Hopefully I'm clear in what I want. If need be, I could post the spreadsheet.
    Thanks very much!
    Dave
    Last edited by dallston; 01-28-2009 at 02:31 PM. Reason: solved

  2. #2
    Forum Expert
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2010
    Posts
    2,561

    re: Additional criteria for 'sumproduct' formula

    You're so close.

    Someone more thoughtful than me will post a good link to an explanation of this kind of formula so you can work it out for yourself in future...

    =SUMPRODUCT((Comparison!F$1:F$20000="X")*(Comparison!$A$1:$A$20000=$A7)*(B$1:B$200000<>"X"))

    HTH
    Last edited by Cheeky Charlie; 01-28-2009 at 12:52 PM. Reason: it's a not...

  3. #3
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,444

    re: Additional criteria for 'sumproduct' formula

    Hi,

    Will this

    Please Login or Register  to view this content.
    do it for you?
    Rule 1: Never merge cells
    Rule 2: See rule 1

    "Tomorrow I'm going to be famous. All I need is a tennis racket and a hat".

  4. #4
    Registered User
    Join Date
    01-28-2009
    Location
    Ottawa, Canada
    MS-Off Ver
    Excel 2003
    Posts
    4

    re: Additional criteria for 'sumproduct' formula

    Hello
    Thanks to both of you for your help. Unfortunately, it appears neither solution works.

    The first solution (from Charlie) does not affect the results at all, and the second solution (from Sweep) does not remove the counts when B=X.

    I'll attach a quick sample spreadsheet, to show you what I mean. As you can see, in TabA, it is showing CFSU(Ottawa) has having a count of 2. However, in the 'Comparison' tab, CFSU(Ottawa) has only 1 occurence of "X" in column C when there is no X in column B. There are 2 total occurences, but the one in line 37 should not be counting, because of the "X" in col B.

    I hope this helps explain better what I'm getting at, its probably just me not being clear at first. Thanks!
    Attached Files Attached Files

  5. #5
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Additional criteria for 'sumproduct' formula

    It looks like CC's will work, but he forgot to reference the Sheetname too in the last argument...

    so should be:

    =SUMPRODUCT((Comparison!C$1:C$20000="X")*(Comparison!$A$1:$A$20000=$B6)*(Comparison!B$1:B$20000<>"X"))
    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.

  6. #6
    Forum Expert
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2010
    Posts
    2,561

    Re: Additional criteria for 'sumproduct' formula

    It looks like CC's will work, but he forgot to reference the Sheetname too in the last argument...
    *oops*

    actually I just copied and edited the formula as written by the OP (lazy, or just presumptuous?); nice attention to detail NBVC

  7. #7
    Registered User
    Join Date
    01-28-2009
    Location
    Ottawa, Canada
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Additional criteria for 'sumproduct' formula

    That works! The <> in the formula is what I needed. I guess I had just read Charlie's post before he did the edit. So thats perfect. Thanks very much all!
    Dave

  8. #8
    Forum Expert
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2010
    Posts
    2,561

    Re: Additional criteria for 'sumproduct' formula

    Of course, there was no need for a sumproduct formula in the first place... although it's the most practical solution now, with two criteria.

    SUMIF is faster and neater where there is only one criterion.

    CC

    PS And you're welcome, please mark the thread as solved ~CC

+ 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