+ Reply to Thread
Results 1 to 11 of 11

Formula that finds the proper combination based on a certain quantity

  1. #1
    Registered User
    Join Date
    11-16-2017
    Location
    Los Angeles, California
    MS-Off Ver
    Microsoft Excel 2013 32-bit
    Posts
    6

    Formula that finds the proper combination based on a certain quantity

    Hey all:

    I am not sure if this will be a formula or maybe it is VBA which is something I'm not too proficient in, so please let me know.

    I have two different types of trucks.

    Truck Type A rents for $325 and holds 75 panels
    Truck Type B rents for $450 and holds 150 panels

    I want a formula that will choose the cheapest combination of trucks up to 10,000 panels

    So if we have 75 panels it will choose Truck A
    If we have 76 panels it will choose one Truck B
    If we have 150 panels it will choose one Truck B
    If we have 151 panels it will choose one Truck A and one Truck B
    and so forth up until we reach 10,000 panels

    I could create a whole table I suppose and reference that with an if or lookup option but I am wondering if there is a cleaner/easier/less time consuming way to do this

    Thanks for any and all suggestions

  2. #2
    Forum Expert avk's Avatar
    Join Date
    07-12-2007
    Location
    India
    MS-Off Ver
    Microsoft Office 2013
    Posts
    3,223

    Re: Formula that finds the proper combination based on a certain quantity

    If you attach sample file, with desired result it will more helpful.


    atul


    If my answer (or that of other members) has helped you, please say "Thanks" by clicking the Add Reputation button at the foot of one of their posts.

    Also: if your problem is solved, please take the time to mark your thread as SOLVED by going to the top of your first post, selecting "Thread Tools" and then "Mark thread as solved".

  3. #3
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: Formula that finds the proper combination based on a certain quantity

    How thoroughly have you analyzed the problem? It looks like you have convinced yourself that you will preferentially use type B trucks, with the occasional type A truck thrown in. Based on what I can see:

    1) The number of type B trucks will be INT(panels/150).
    2) If the number of remaining panels is 75 or less, then add a type A truck, else add another type B truck.

    Does that seem like a correct algorithm? As those should be relatively simple Excel formulas, can you piece them together, or do you need help putting the formulas together?
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  4. #4
    Registered User
    Join Date
    11-16-2017
    Location
    Los Angeles, California
    MS-Off Ver
    Microsoft Excel 2013 32-bit
    Posts
    6

    Re: Formula that finds the proper combination based on a certain quantity

    So you are saying that if the quantity can be divided by 150 then it will choose truck B.

    Can you help me with this? I've never used the INT formula before.

  5. #5
    Registered User
    Join Date
    11-16-2017
    Location
    Los Angeles, California
    MS-Off Ver
    Microsoft Excel 2013 32-bit
    Posts
    6

    Re: Formula that finds the proper combination based on a certain quantity

    Quote Originally Posted by MrShorty View Post
    How thoroughly have you analyzed the problem? It looks like you have convinced yourself that you will preferentially use type B trucks, with the occasional type A truck thrown in. Based on what I can see:

    1) The number of type B trucks will be INT(panels/150).
    2) If the number of remaining panels is 75 or less, then add a type A truck, else add another type B truck.

    Does that seem like a correct algorithm? As those should be relatively simple Excel formulas, can you piece them together, or do you need help putting the formulas together?
    So you are saying that if the quantity can be divided by 150 then it will choose truck B.

    Can you help me with this? I've never used the INT formula before.

  6. #6
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: Formula that finds the proper combination based on a certain quantity

    So you are saying that if the quantity can be divided by 150 then it will choose truck B.
    I thought that's what your description was telling me, so I guess so. Do you agree?

    The INT() formula (help file https://support.office.com/en-us/art...a-cb1fd9d343ef ) simply rounds a number down to the nearest integer. The formula for step 1 simply states that the number of Type B truck will be the number of 150 panel lots/groups there are in the shipment. Again, would you agree with this, or is there some complexity that I am missing?

  7. #7
    Registered User
    Join Date
    11-16-2017
    Location
    Los Angeles, California
    MS-Off Ver
    Microsoft Excel 2013 32-bit
    Posts
    6

    Re: Formula that finds the proper combination based on a certain quantity

    So this is what I have so far, but there is an error that happens when I get to 226. It is choosing 2 small trucks and 1 big instead of 2 big. Thoughts?

    # of Panels: B2
    Big Truck: =IF(AND(B2>75,B2<150),1,QUOTIENT(B2,150))
    Small Truck: =IF(B4=-1,0,ROUNDUP((B2-150*B3)/75,0))

  8. #8
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: Formula that finds the proper combination based on a certain quantity

    I am not quite following your logic in these two functions. Are you trying to use the same logic as before, or are you using a different logic/algorithm?

    For the algorithm I had envisioned:
    1) B2 is the number of panels.
    2) B3 is the main number of large trucks =INT(B2/150) or =INT(QUOTIENT(B2,150)) if you want to use the QUOTIENT() function.
    3) B4 is for the additional large truck, if the remainder is greater than 75 =IF(B2-B3>75,1,0) or
    3a) =B3+IF(B2-B3>75,1,0) if you want B4 to be the final tally of large trucks.
    4) B5 is for the small truck, if needed =IF(AND(0<B2-B3,B2-B3<=75),1,0)

    Is that the algorithm you are trying to use for this, or is there something else that needs to be considered?

  9. #9
    Valued Forum Contributor jtakw's Avatar
    Join Date
    05-05-2018
    Location
    CA, USA
    MS-Off Ver
    2016
    Posts
    668

    Re: Formula that finds the proper combination based on a certain quantity

    Hi,

    Well, let's just get it done for OP...

    Columns A and B are not really necessary, just for informational purposes Only.
    Follow the logic of this sample and apply it to your set up:

    Excel 2016 (Windows) 64 bit
    A
    B
    C
    D
    E
    F
    G
    1
    Truck Type Cost Capacity Panels Truck B Needed Truck A Needed
    2
    A
    325
    75
    75
    0
    1
    3
    B
    450
    150
    76
    1
    0
    4
    150
    1
    0
    5
    151
    1
    1
    6
    900
    6
    0
    7
    950
    6
    1
    8
    1000
    7
    0
    9
    1100
    7
    1
    Sheet: Sheet69

    Excel 2016 (Windows) 64 bit
    F
    G
    2
    =INT(E2/C$3)+IF(MOD(E2,C$3)>C$2,1,0)
    =IF(F2*C$3>=E2,0,1)
    Sheet: Sheet69

  10. #10
    Valued Forum Contributor jtakw's Avatar
    Join Date
    05-05-2018
    Location
    CA, USA
    MS-Off Ver
    2016
    Posts
    668

    Re: Formula that finds the proper combination based on a certain quantity

    Don't want to confuse OP, so I'll post this separately, basically the same formulas, just written "short-hand":

    Excel 2016 (Windows) 64 bit
    A
    B
    C
    D
    E
    F
    G
    1
    Truck Type Cost Capacity Panels Truck B Needed Truck A Needed
    2
    A
    325
    75
    75
    0
    1
    3
    B
    450
    150
    76
    1
    0
    4
    150
    1
    0
    5
    151
    1
    1
    6
    900
    6
    0
    7
    950
    6
    1
    8
    1000
    7
    0
    9
    1100
    7
    1
    Sheet: Sheet69

    Excel 2016 (Windows) 64 bit
    F
    G
    2
    =INT(E2/C$3)+N(MOD(E2,C$3)>C$2)
    =N(F2*C$3<E2)
    Sheet: Sheet69

  11. #11
    Registered User
    Join Date
    11-16-2017
    Location
    Los Angeles, California
    MS-Off Ver
    Microsoft Excel 2013 32-bit
    Posts
    6

    Re: Formula that finds the proper combination based on a certain quantity

    Legit no clue how you know how to do that but it is awesome and it worked and I am extremely appreciative!!!!!

+ 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] Formula to works out Full box Quantity and Part box quantity as well,
    By pmw19800 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-13-2018, 08:59 AM
  2. [SOLVED] I need help on a formula where I find an item and quantity based on a specific date
    By Pickled Shark in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 03-28-2017, 02:01 PM
  3. Dynamic cell formula based on quantity entry
    By MICowboy13 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 05-21-2015, 11:11 AM
  4. Formula - Counting a combination based in two colums
    By Jakes1991 in forum Excel General
    Replies: 6
    Last Post: 04-02-2015, 04:50 AM
  5. [SOLVED] Formula's value based off combination of two other cells
    By kosherboy in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-10-2014, 10:35 PM
  6. Replies: 5
    Last Post: 08-10-2011, 05:06 PM
  7. Replies: 5
    Last Post: 11-23-2009, 06:24 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