+ Reply to Thread
Results 1 to 14 of 14

Creation formula with multiple criterias

  1. #1
    Registered User
    Join Date
    10-23-2008
    Location
    Spb
    Posts
    12

    Question Creation formula with multiple criterias

    Hi! I need a formula with an idea simular to that of SUMIF, but I need several "IF" and several criteria for each of them. Let me describe, here is the data:

    Name Plant Room Stock
    A 2110 1010 1,000
    A 2110 2,000
    A 3010 3010 3,000
    A 2130 2010 4,000
    B 2120 1020 5,000
    B 2120 2020 6,000
    B 2130 7,000
    B 2130 1010 8,000
    B 2130 2010 9,000

    In the other table I want to find out, what is the total stock of A that is on plants 2110, 3010 in rooms 1010,"", 2020. (There are several rooms in each palnt).

    so formula must contain this logic: Sum of Stock if Name is A and Plant is 2110 or 3010 and rooms are 1010,"" or 2020.

    I found a solution via massive formula, but the real situation is so that there are 500 names, 50 plants and 50 rooms, and I may need up to ten criterias for plant and the same for room, as the data consists of 10000 lines, and I need the outpoot of total stock for each name on certain plants in certain rooms.

    In this situation massive megaformula becomes too long to fit in one cell, moreover calculation is too long.

    The best result is to create (write in basic or whatever and implant it in excell) a fomula like SUMIF with several possible criterias and ranges of values that fit each of them.

    Is it somehow possible?

    If the situation is not clear enough, I can provide the massive formula that is the solution for now.
    Last edited by s-vadik; 10-24-2008 at 02:44 AM.

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

    =SUMPRODUCT((A2:A10="A")*(B2:B10={2110,3010})*((C2:C10={1010,2020})+(C2:C10=""))*D2:D10)

    Where A2:C10 contains your original data

    Note: If your Plant and Room numbers are text entries instead of numerical...then surround those entries in the formula in double quotes.
    Last edited by NBVC; 10-23-2008 at 03:21 AM. Reason: Fixed small error in formula
    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.

  3. #3
    Valued Forum Contributor rwgrietveld's Avatar
    Join Date
    09-02-2008
    Location
    Netherlands
    MS-Off Ver
    XL 2007 / XL 2010
    Posts
    1,671

    re: Creation formula with multiple criterias

    NBVC gave the correct function. I would use it. nevertheless I would like to show you a way that you can use when the criteria change over time. The way is to use Advanced Filter. I have added a workbook for you to see the actual criteria and the result table. If you put the ActiceCell in the original table and press data->Filter->Advanced Filter, you'll be able to update the result table.

    Hope it helps
    Attached Files Attached Files
    Looking for great solutions but hate waiting?
    Seach this Forum through Google

    www.Google.com
    (e.g. +multiple +IF site:excelforum.com/excel-general/ )

    www.Google.com
    (e.g. +fill +combobox site:excelforum.com/excel-programming/ )

    Ave,
    Ricardo

  4. #4
    Registered User
    Join Date
    10-23-2008
    Location
    Spb
    Posts
    12

    Question

    I'm testing this way.

    But here comes a question - if we go this way, 10-values massive of FALSE and TRUE is multiplied by 20-values massive of F&T. I can not understand the logic, on which this operation is based.

    And more generally, can you provide the rules of multipleing two F&T massives of not the same number of values. I can't formulize the question to search the web, i can only find multipleing of matrix this way!

  5. #5
    Valued Forum Contributor rwgrietveld's Avatar
    Join Date
    09-02-2008
    Location
    Netherlands
    MS-Off Ver
    XL 2007 / XL 2010
    Posts
    1,671

    re: Creation formula with multiple criterias

    Multiplying the F&T is easier understood if you first multiply these with 1 or --. Then the TRUE will be one (1) and the False will be 0 (zero). Further you can follow what is happening with the evaluate function. In array functions like Sumproduct this is VERY helpfull.

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

    I created a table of criteria to use in the formula.

    You just have to add all your criteria and adjust ranges in formula to satisfy:

    Formula used in J2:

    Please Login or Register  to view this content.
    Note: Checking for the blank entry is kept separate
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    10-23-2008
    Location
    Spb
    Posts
    12
    rwgrietveld

    This way is not acceptable, because
    1) in the criteria we must mention all possible combinations of plant - room
    2) then summ the result
    3) repeat action of filtering for each of 500 names.

    It is too hard as there are 50^2 combinations of plant-room, here a formula is needed, not filtering. But thanks for try!

  8. #8
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    Please see my last post and attachment.

  9. #9
    Registered User
    Join Date
    10-23-2008
    Location
    Spb
    Posts
    12
    NBVC

    It is great, thanks a lot! Now I'm testing this on practice to find out whether calculations would be in a reasonable time, but the way is really good, I think I would have never found it myself!

    One more question - I want to generalise the situation - is it possible to include room "" in the common range or criteria, but adding
    '+($C$2:$C$10="")' separetely to the formula?

  10. #10
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    Not sure what you mean.. can you elaborate?

  11. #11
    Registered User
    Join Date
    10-23-2008
    Location
    Spb
    Posts
    12
    Of course!

    In the file you have provided the range of criteria for room is set. They are
    1010
    2020
    2130

    But also we need a room with noname - "". If we expand the range to one more empty cell, it doesn't work - so you add this part to the final formula
    '+($C$2:$C$10="")' to count stock in room "" as well.

    It works, but if the situation changes and we no longer need the room "", I can not just change values in CRITERIA range, I must change the final formula to exclude this part.

    I want to make it more general - find a way to poot room "" together with all the other criterias in the CRITERIA range and make it work.

    One way is to change "" to "-" in the data, but this table is formed by SAP each day, and I'm not sure it would be possible to do it automatically.

    I tried to be clear)

  12. #12
    Registered User
    Join Date
    10-23-2008
    Location
    Spb
    Posts
    12
    rwgrietveld

    I understand that T = 1 & F = 0 and the rules of multiplying massives if they consist of the same number of values, ex

    {a1;a2;a3;a4;a5} * {b1;b2;b3;b4;b5} = {a1*b1;a2*b2;a3*b3;a4*b4;a5*b5}

    It is clear, but what happens if this number is not the same, ex
    {a1;a2;a3;a4;a5} * {b1;b2;b3} = ???

    Here I don't understant the logic

  13. #13
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    Quote Originally Posted by s-vadik View Post
    Of course!

    In the file you have provided the range of criteria for room is set. They are
    1010
    2020
    2130

    But also we need a room with noname - "". If we expand the range to one more empty cell, it doesn't work - so you add this part to the final formula
    '+($C$2:$C$10="")' to count stock in room "" as well.

    It works, but if the situation changes and we no longer need the room "", I can not just change values in CRITERIA range, I must change the final formula to exclude this part.

    I want to make it more general - find a way to poot room "" together with all the other criterias in the CRITERIA range and make it work.

    One way is to change "" to "-" in the data, but this table is formed by SAP each day, and I'm not sure it would be possible to do it automatically.

    I tried to be clear)
    Possibly you can use this formula...

    Please Login or Register  to view this content.
    Where any of the cells in H2:H5 could contain a blank for the Room #

    This adds a virtual dash to all entries in C and H so that blanks will seem like dash (-) instead.
    Last edited by NBVC; 10-23-2008 at 03:41 PM. Reason: Improved/Revised formula

  14. #14
    Registered User
    Join Date
    10-23-2008
    Location
    Spb
    Posts
    12
    Calculations are a little bit longer than they are willed to be, but I guess there is nothing to do with this. So the problem is totally solved. Thanks a lot!

+ 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