+ Reply to Thread
Results 1 to 17 of 17

Sumproduct with potentially multiple and dynamic or criteria

  1. #1
    Registered User
    Join Date
    06-06-2014
    Location
    Hong Kong
    MS-Off Ver
    2010
    Posts
    91

    Sumproduct with potentially multiple and dynamic or criteria

    Hi guys,

    I'm looking for any potential way to write this formula to be:
    a) user friendly and/or
    b) easier to manage

    Currently, for example, I have a formula that goes like:

    Please Login or Register  to view this content.
    Now from time to time the number of criteria can change (Could have 2, Could have more than 10) and/or the codes might change (Instead of 1.1 it's 2.3 for example).

    Is there anyway to manage this where if it needs changing I don't have to go into the formula to manually edit everything?

    Thanks.

  2. #2
    Forum Expert shukla.ankur281190's Avatar
    Join Date
    05-17-2014
    Location
    Lucknow, India
    MS-Off Ver
    Office 365
    Posts
    3,937

    Re: Sumproduct with potentially multiple and dynamic or criteria

    You have done hard coded comparison, which need to change every time manually according your need. Instead of hard coded you can give reference cell, in reference cell you can put criteria as drop down; if you change dynamically your result as per your selection.

    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.
    If I helped, Don't forget to add reputation (click on the little star ★ at bottom of this post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)

  3. #3
    Registered User
    Join Date
    06-06-2014
    Location
    Hong Kong
    MS-Off Ver
    2010
    Posts
    91

    Re: Sumproduct with potentially multiple and dynamic or criteria

    Don't notice any Go Advanced command or tab.
    With regards to data, I'll have to take a look how to edit everything as some of this is confidentia

  4. #4
    Registered User
    Join Date
    08-22-2016
    Location
    Copenhagen, Denmark.
    MS-Off Ver
    Excel 2016
    Posts
    28

    Re: Sumproduct with potentially multiple and dynamic or criteria

    The 'Go Advanced' tab is here:

    \1

  5. #5
    Registered User
    Join Date
    06-06-2014
    Location
    Hong Kong
    MS-Off Ver
    2010
    Posts
    91

    Re: Sumproduct with potentially multiple and dynamic or criteria

    Ah right thought you meant on excel.

    Example should be uploaded now.

    Ex1 and Ex2 is the before and after, in the sense that different names have different criteria.
    Attached Files Attached Files

  6. #6
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,923

    Re: Sumproduct with potentially multiple and dynamic or criteria

    Try this in C5:

    =IF(RIGHT(B5)="x",SUMPRODUCT(--(Data1!B$1:B$17=$H$2),--(LEFT(Data1!$C$1:$C$17,1)=LEFT(B5,1)),Data1!$D$1:$D$17),SUMPRODUCT(--(Data1!B$1:B$17=$H$2),--(ISNUMBER(SEARCH(Data1!$C$1:$C$17,B5))),Data1!$D$1:$D$17))

  7. #7
    Forum Expert shukla.ankur281190's Avatar
    Join Date
    05-17-2014
    Location
    Lucknow, India
    MS-Off Ver
    Office 365
    Posts
    3,937

    Re: Sumproduct with potentially multiple and dynamic or criteria

    Try

    C5
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Last edited by shukla.ankur281190; 08-31-2016 at 08:31 AM.

  8. #8
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Sumproduct with potentially multiple and dynamic or criteria

    Assuming that examples like 2.1-2.3 should also include intermediate values such as 2.2 in the result.

    Array formula to go into C5, then fill down.

    This formula will interpret x as a wildcard, numbers separated by / as individual criteria, and numbers separated by - as start and end of a sequence.

    PHP Code: 
    =SUMPRODUCT(Data1!$D$2:$D$17*(Data1!B$2:B$17=$H$2)*IF(ISNUMBER(SEARCH("-",B5)),((--LEFT(Data1!$C$2:$C$17,3))>=(--LEFT(B5,3)))*((--LEFT(Data1!$C$2:$C$17,3))<=(--RIGHT(B5,3))),ISNUMBER(1/(SEARCH(MID(SUBSTITUTE(B5,".x","**"),(COLUMN($A$1:INDEX($1:$1,CEILING(LEN(B5),4)/4))-1)*4+1,3),Data1!$C$2:$C$17)=1)))) 
    ...confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer.

  9. #9
    Registered User
    Join Date
    06-06-2014
    Location
    Hong Kong
    MS-Off Ver
    2010
    Posts
    91

    Re: Sumproduct with potentially multiple and dynamic or criteria

    Ah crap, sorry guys. Column B is misleading. While yes it is related to code, That section is supposed to be text only i.e. Names of code descriptors.
    I've removed the names and just kept numbers for easier understanding.
    You won't be able to use column B for formulas sorry

  10. #10
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2404
    Posts
    13,407

    Re: Sumproduct with potentially multiple and dynamic or criteria

    Another way.

    As shukla.ankur281190 has suggested rather that hard code the criteria set up the sheets so the criteria can be referenced. Those references can be done dynamically as the "codes" change.

    This is all done in Ex1. It can be duplicated in Ex2.

    Try parsing the "codes" that are in column B with this formula in G5:I8. These will be helper columns for dynamic referencing.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Then use this formula in C5:C8
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Be sure to append "" to the parts Data1!$C$1:$C$17&"" as in the formula and the attached. Data1!$C$1:$C$17 are mixed numbers and text and need to match the text output of the parsed "codes". This also eliminates the need for calling the LEFT function.
    Last edited by FlameRetired; 09-01-2016 at 12:52 AM.
    Dave

  11. #11
    Registered User
    Join Date
    06-06-2014
    Location
    Hong Kong
    MS-Off Ver
    2010
    Posts
    91

    Re: Sumproduct with potentially multiple and dynamic or criteria

    Will take a look and try to understand the formula.
    Not used them before so no idea what it means :P
    But thanks for the example.
    It's a little clunky if I need 10 codes in one line however but I guess short of designing and programming a software tool, this is the best I can do to make it as user friendly as possible for excel (Other people with little knowledge in excel with have to use the sheet also).

    Thanks everyone for the input though, it's all much appreciated.
    If anyone has any other shortcuts to add though please feel free to do so

  12. #12
    Registered User
    Join Date
    06-06-2014
    Location
    Hong Kong
    MS-Off Ver
    2010
    Posts
    91

    Re: Sumproduct with potentially multiple and dynamic or criteria

    After looking at that formula more closely I noticed we're still using column B for the data. In the real spreadsheet the codes may not be displayed as it'll be replaced with text descriptors.
    We will still also have to manually change the formula in column C if we need to add more criteria.
    Yes that's not difficult but Christ try telling that to my colleagues.
    Essentially what I am looking for is.
    1. Copy paste raw data into worksheet "Data1"
    2. Change name H2 as necessary.
    3. Done.
    4. maybe if we need to change code criteria I type in some code numbers "1.1, 2.3, etc." in a separate cell and the formula in col C reads it and automatically changes. 1 criteria, 20 criteria, code 1.1 or code 1.x, it'll still work the same.

    It doesn't have to be sumproduct, that's just what I know.
    Though I'm not sure what else would work.

    Am I being too overly optimistic and essentially what I'm asking for is, again, short of impossible except for a custom software program?

    If it's not that simple they won't have a clue

  13. #13
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Sumproduct with potentially multiple and dynamic or criteria

    Quote Originally Posted by Gunblade View Post
    Column B is misleading. While yes it is related to code, That section is supposed to be text only i.e. Names of code descriptors.
    You will need to provide a new sample file that is not misleading if you still want an answer.

    If you only have names of code descriptors in column B, then you will need to provide the information to compare the text to the raw data.

  14. #14
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2404
    Posts
    13,407

    Re: Sumproduct with potentially multiple and dynamic or criteria

    I concur with what jason.b75 says above.

    Quote Originally Posted by Gunblade View Post
    ...............It's a little clunky if I need 10 codes in one line however but I guess short of designing and programming a software tool, this is the best I can do to make it as user friendly as possible for excel (Other people with little knowledge in excel with have to use the sheet also)...........
    In the meantime, even with a new upload, some kind of parsing step might be necessary.

    This does not have to be done with helper columns as in my previous upload. That parsing can be done with an array embedded in-formula. Even then it would be advantageous to have 1 helper column that calculates the number of "codes" criteria in each row of column B. That will be automatic and can be hidden.

    It still makes for a lengthy array-entered formula. If you aren’t familiar with array-entered formulas array enter means the formula must be committed from edit mode by simultaneously pressing and holding down Ctrl and Shift while hitting Enter. That may be confusing to colleagues. Also the one I have using the current data is about 2 lines long.

    I overlooked something earlier.

    It appears that some of the criteria have criteria as well. "Codes" criteria ending in ".x" are special cases.

    I do not think we can help you further without a more representative (desensitized) example. Please feel free to include 10-20 "codes" criteria in some rows.

  15. #15
    Registered User
    Join Date
    06-06-2014
    Location
    Hong Kong
    MS-Off Ver
    2010
    Posts
    91

    Re: Sumproduct with potentially multiple and dynamic or criteria

    Will see what I can do, busy at work preparing for some business trips. May be today or sometime next week, thanks

  16. #16
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2404
    Posts
    13,407

    Re: Sumproduct with potentially multiple and dynamic or criteria

    Looking forward to it.

  17. #17
    Registered User
    Join Date
    06-06-2014
    Location
    Hong Kong
    MS-Off Ver
    2010
    Posts
    91

    Re: Sumproduct with potentially multiple and dynamic or criteria

    Almost forgot about this.
    Example 2 attached with comments in the spreadsheet.
    Attached Files Attached Files

+ 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. Replies: 10
    Last Post: 06-24-2014, 09:36 AM
  2. Replies: 6
    Last Post: 08-04-2013, 11:53 AM
  3. Replies: 5
    Last Post: 04-20-2012, 08:54 AM
  4. Replies: 1
    Last Post: 01-21-2011, 07:24 AM
  5. Sumproduct with multiple criteria & dynamic range
    By e_lad in forum Excel General
    Replies: 10
    Last Post: 03-17-2010, 09:15 AM
  6. Multiple dynamic ranges in a Sumproduct
    By mmartens12 via OfficeKB.com in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-01-2006, 11:30 PM
  7. Replies: 1
    Last Post: 09-19-2005, 10: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