+ Reply to Thread
Results 1 to 20 of 20

Formula to find the minimum value with constraint

  1. #1
    Registered User
    Join Date
    04-03-2014
    Location
    Dallas, USA
    MS-Off Ver
    Excel 2003
    Posts
    14

    Formula to find the minimum value with constraint

    I have a simple table with A, B, and C columns and D, E, F rows and numeric values in each cell of the table. I need to get one value from each column (only one value per column) that will result in the lowest possible number when adding those values up. There is one constraint: I can not get cells that belong to the same row.

    On the example I am providing, the sum of the cells highlighted in green totals 1978 which is the lowest possible result on that table provided that I'm selecting one cell per column and each selected cell belongs to an unique row.

    Is there an excel formula for this problem? I looking for a formula to provide what the lowest possible number is and also need to identify the cells being selected.

    Thanks in advance.
    Attached Files Attached Files
    Last edited by LBala; 04-04-2014 at 08:32 AM.

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Help needed on finding a formula for this...

    Whether any two duplicate values can be present in a column?


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Registered User
    Join Date
    03-30-2014
    Location
    Suzhou,China
    MS-Off Ver
    Excel 2003
    Posts
    41

    Re: Help needed on finding a formula for this...

    Just for the data in Attached Files:

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Enter this array formula with Ctrl+Shift+Enter.

    this formula is too long,see #7
    Last edited by wcymiss; 04-04-2014 at 09:44 AM. Reason: modify formula
    Welcome to China,Welcome to Suzhou...And,我是来学英文的。

  4. #4
    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: Help needed on finding a formula for this...

    wcymiss


    Your post does not comply with Rule 7 of our Forum RULES. Please do not ignore requests by Administrators, Moderators and senior forum members regarding forum rules.

    If you are unclear about the request or instruction then send a private message to them asking for clarification. Do not post a reply in a thread where a moderator has requested an action that has not yet been complied with e.g Title change or Code tags...etc
    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.

  5. #5
    Registered User
    Join Date
    04-03-2014
    Location
    Dallas, USA
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: Help needed on finding a formula for this...

    No, there is no duplicate values in the same column. There are no duplicate values in the same row either.
    Thanks.

  6. #6
    Registered User
    Join Date
    04-03-2014
    Location
    Dallas, USA
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: Help needed on finding a formula for this...

    Sorry about that. I just changed the title.
    Thanks.

  7. #7
    Registered User
    Join Date
    03-30-2014
    Location
    Suzhou,China
    MS-Off Ver
    Excel 2003
    Posts
    41

    Re: Formula to find the minimum value with constraint

    Hi, LBala

    I have modified my formula like this:

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Do not forget press Ctrl+Shift+Enter when you enter the array formula.

  8. #8
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Formula to find the minimum value with constraint

    That's simply incredible, wcymiss.
    Click * below if this answer helped

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

  9. #9
    Registered User
    Join Date
    03-30-2014
    Location
    Suzhou,China
    MS-Off Ver
    Excel 2003
    Posts
    41
    Quote Originally Posted by XOR LX:3650027
    That's simply incredible, wcymiss.
    Thank you,XORLX
    Your praise is my best to encourage

  10. #10
    Registered User
    Join Date
    04-03-2014
    Location
    Dallas, USA
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: Formula to find the minimum value with constraint

    Your solution is mind boggling wcymiss, I honestly thought no one would come up with a single formula for that. The formula really startled me and I am still trying to understand how it works!

    If the table has 6 columns and 6 rows, how would the formula be? I tried changing it to apply to a 6x6 table but could not...

    Also, what I am missing is where to locate the selected values on the table, any suggestion on how to do it?

    Thanks for the reply. Your solution for the problem really caused an impression on me...

  11. #11
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Formula to find the minimum value with constraint

    Hi wcymiss,

    Handled it so nicely with indepth processing of worksheet functions

    I think you made a good start here and waiting to learn lot more from your posts

  12. #12
    Registered User
    Join Date
    03-30-2014
    Location
    Suzhou,China
    MS-Off Ver
    Excel 2003
    Posts
    41

    Re: Formula to find the minimum value with constraint

    Hi LBala,

    If the table has 6 columns and 6 rows,the formula should like this :

    =MIN(IF(MMULT(FIND({1,2,3,4,5,6},ROW(123456:654321)&123456),{1;1;1;1;1;1})=6,MMULT(N(OFFSET(B2,{1,2,3,4,5,6},MID(ROW(123456:654321),{1,2,3,4,5,6},1))),{1;1;1;1;1;1})))

    and the data must be in [C3:H8]. "B2" in formula is the "above-left" cells of your data area.

    Sorry,my english is poor,I dont kown how to say that,could you understand me?

    ------------------------------------------

    Hi Sixthsense,
    I'm glad to hear that,thank you for compliment.


    ------------------------------------------
    Sorry to reply so late.
    Today is Chinease Qingming Festival,a day for remembering our dead relatives.
    Last edited by wcymiss; 04-05-2014 at 10:29 AM.

  13. #13
    Registered User
    Join Date
    04-03-2014
    Location
    Dallas, USA
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: Formula to find the minimum value with constraint

    Hi wcymiss;

    Your english is good, I understand perfectly what you're writing.
    The above formula is not working on a 6x6 table, it returns a 0 result... Have you tested it?

    By the way, how did you come up with the "=6" in the formula? What's the idea behind it?
    Thanks for taking up this challenge.

  14. #14
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Formula to find the minimum value with constraint

    I believe that the 6 should actually be 21 (the sum of integers from 1-6) in that new version.

    Regards

  15. #15
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Formula to find the minimum value with constraint


  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: Formula to find the minimum value with constraint

    So....

    Your post does not comply with Rule 8 of our Forum RULES. Do not crosspost your question on multiple forums without including links here to the other threads on other forums.

    Cross-posting is when you post the same question in other forums on the web. The last thing you want to do is waste people's time working on an issue you have already resolved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser) to the cross-post.

    Expect cross-posted questions without a link to be closed and a message will be posted by the moderator explaining why. We are here to help so help us to help you!

    Read this to understand why we ask you to do this, and then please edit your first post to include links to any and all cross-posts in any other forums (not just this site).

  17. #17
    Registered User
    Join Date
    04-03-2014
    Location
    Dallas, USA
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: Formula to find the minimum value with constraint

    21 inside the formula for the 6x6 table works.
    Last edited by LBala; 04-05-2014 at 08:21 PM.

  18. #18
    Registered User
    Join Date
    03-30-2014
    Location
    Suzhou,China
    MS-Off Ver
    Excel 2003
    Posts
    41

    Re: Formula to find the minimum value with constraint

    Sorry LBala,I make a mistake because my carelessness.

    As XorLX say, the 6 should actually be 21,it is the sum of integers from 1-6.

    However,this formula has a circular reference issues.If your data area is [C3:H8],
    when you enter this formula in any cell of [I3:K8] you will receive a warning about the circular reference.

    other,ROW(123456:654321) will take too many time,so I modifid this formula like this:

    Please Login or Register  to view this content.
    46656=6^6, and 9^9 is a larger number then the sum of all numbers in your data.

    because excel has only 1048576 rows,you can only calculate the table of 7*7.if the table has 8 columns and 8 rows(8^8=16777216),you can't use this formula to get the result.I'm afraid you should get help from VBA.

  19. #19
    Registered User
    Join Date
    04-03-2014
    Location
    Dallas, USA
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: Formula to find the minimum value with constraint

    Thanks for the help once again wcymiss, you are fantastic!

  20. #20
    Forum Expert icestationzbra's Avatar
    Join Date
    01-07-2004
    MS-Off Ver
    2007, 2010
    Posts
    1,421

    Re: Formula to find the minimum value with constraint

    this array formula is just an attempt to simplify the wonderful, albeit very complicated, formula that wcymiss has offered. for those who may not be able / willing to use that formula because of its complexity, this formula might help you in understanding what wcymiss' is doing in a much more automated fashion:

    Please Login or Register  to view this content.
    or

    Please Login or Register  to view this content.
    to wcymiss, i tip my hat...
    Last edited by icestationzbra; 04-08-2014 at 09:53 AM. Reason: removed unnecessary argument
    - i.s.z -
    CSE, aka Array aka { }, formulae are confirmed with CONTROL+SHIFT+ENTER.
    Replace commas ( , ) with semicolons ( ; ) in formulae, if your locale setting demands.
    All good ideas are courtesy resources from this forum as well as others around the web.
    - e.o.m -

+ 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] Comparing two rows to two rounds and finding what is needed
    By acme1 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-13-2014, 07:22 AM
  2. Formula needed for finding unique values
    By mflynn in forum Excel General
    Replies: 2
    Last Post: 04-07-2010, 05:14 PM
  3. Finding the Min number needed, for bottom cell to be greater than top?
    By Newbie2007 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-17-2009, 09:54 AM
  4. Help Needed with Finding a Function
    By lsmith in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 02-23-2006, 09:30 AM
  5. Help needed in finding specific series via row.
    By hadmybreaktoday in forum Excel Formulas & Functions
    Replies: 43
    Last Post: 09-06-2005, 07: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