+ Reply to Thread
Results 1 to 12 of 12

Sum the cost of the selected ingredients for each burger, to give total cost of burger.

  1. #1
    Registered User
    Join Date
    12-04-2013
    Location
    Oxford, England
    MS-Off Ver
    Excel 2000
    Posts
    93

    Sum the cost of the selected ingredients for each burger, to give total cost of burger.

    Hi,

    I am re-making this thread because the earlier one ("Is this component included? Ok then add to total cost." - http://www.excelforum.com/excel-form...otal-cost.html) turned out to be too vague.

    This time, l have also attached an example spreadsheet for illustration - please see attachment.

    As the title of this new thread indicates: I have several burgers on a menu. Each burger uses a different set of ingredients. Each ingredient has a specific cost, listed in the "Ingredient costs" subsection of the spreadsheet.

    For each burger: Wherever an ingredient is specified, l want its cost to be cross-referenced from the "Ingredient costs" subsection, and added to the cost of all other ingredients for that burger, and l want the sum placed in the "Total Cost of this burger" column.

    Caveat: Whenever Ingredient D has been selected with a "Y", the cost of Ingredient D is only added to Column J if Column F ("Is D available?") also has a "Y"
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    01-16-2014
    Location
    Istanbul, Turkey
    MS-Off Ver
    Excel 2010
    Posts
    35

    Re: Sum the cost of the selected ingredients for each burger, to give total cost of burger

    try this one, i transpozed ingredient list to make sumproduct work, and changed how ingredient d works
    Attached Files Attached Files

  3. #3
    Forum Expert
    Join Date
    02-19-2013
    Location
    India
    MS-Off Ver
    07/16
    Posts
    2,386

    Re: Sum the cost of the selected ingredients for each burger, to give total cost of burger

    One approach could be copy paste below in J2 then hold control and shift together and hit enter to make array formula
    =SUM(IF(MID(IF($B2:$D2="y",$B$1:$D$1,0),12,1)=$L$2:$L$8,$M$2:$M$8))+SUM(IF(MID(IF($G2:$I2="y",$G$1:$I$1,0),12,1)=$L$2:$L$8,$M$2:$M$8))+SUM(IF(AND(E2="y",F2="y"),$M$5))
    -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    WANT TO SAY THANKS, HIT ADD REPUTATION (*) AT THE BOTTOM LEFT CORNER OF THE POST

    More we learn about excel, more it shows us, how less we know about it.

    for chemistry
    https://www.youtube.com/c/chemistrybyshivaansh

  4. #4
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,334

    Re: Sum the cost of the selected ingredients for each burger, to give total cost of burger

    Hi catsqueezer,

    I'm third to give an answer, but see it attached using SumProduct

    http://www.meadinkent.co.uk/xlsumproduct.htm
    Attached Files Attached Files
    Last edited by MarvinP; 03-20-2014 at 09:50 AM.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  5. #5
    Valued Forum Contributor
    Join Date
    05-13-2010
    Location
    Belo Horizonte, Brazil
    MS-Off Ver
    Excel 2003; 2007
    Posts
    441

    Re: Sum the cost of the selected ingredients for each burger, to give total cost of burger

    CatSqueezer, Good morning.

    Take a look at it.
    20-03-2014_ExcelForum_Book1.xls

    Is it what you want?
    I hope it helps.
    ...If my answer helped you, Please, click on. * Add Reputation (at left)

    Best regards.
    Marc?lio Lob?o

  6. #6
    Registered User
    Join Date
    12-04-2013
    Location
    Oxford, England
    MS-Off Ver
    Excel 2000
    Posts
    93

    Re: Sum the cost of the selected ingredients for each burger, to give total cost of burger

    Hi bolulusam, your solution works except for the caveat But thank you for what you did.

  7. #7
    Registered User
    Join Date
    12-04-2013
    Location
    Oxford, England
    MS-Off Ver
    Excel 2000
    Posts
    93

    Re: Sum the cost of the selected ingredients for each burger, to give total cost of burger

    Quote Originally Posted by hemesh View Post
    One approach could be copy paste below in J2 then hold control and shift together and hit enter to make array formula
    =SUM(IF(MID(IF($B2:$D2="y",$B$1:$D$1,0),12,1)=$L$2:$L$8,$M$2:$M$8))+SUM(IF(MID(IF($G2:$I2="y",$G$1:$I$1,0),12,1)=$L$2:$L$8,$M$2:$M$8))+SUM(IF(AND(E2="y",F2="y"),$M$5))
    Hi hemesh, your solution works, thanks! Rep point on its way

  8. #8
    Registered User
    Join Date
    12-04-2013
    Location
    Oxford, England
    MS-Off Ver
    Excel 2000
    Posts
    93

    Re: Sum the cost of the selected ingredients for each burger, to give total cost of burger

    Hi MarvinP, your solution doesn't work, the values it gives are too high, and it ignores the caveat. Sorry

  9. #9
    Registered User
    Join Date
    12-04-2013
    Location
    Oxford, England
    MS-Off Ver
    Excel 2000
    Posts
    93

    Re: Sum the cost of the selected ingredients for each burger, to give total cost of burger

    HI Mazzaropi, your solution is the most elegant, and it doesn't even need an array. Thank you very much, l have adapted and used it (l don't need the Vlookup actually, l refer directly to value cells, instead of referring to the titles of those cells). Rep point on its way!

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

    Re: Sum the cost of the selected ingredients for each burger, to give total cost of burger

    put this in J3 of Mazzaropi's file from post #5 and drag-fill down:

    Please Login or Register  to view this content.
    or a little less robust,

    Please Login or Register  to view this content.
    Last edited by icestationzbra; 03-22-2014 at 12:37 AM.
    - 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 -

  11. #11
    Forum Expert
    Join Date
    02-19-2013
    Location
    India
    MS-Off Ver
    07/16
    Posts
    2,386

    Re: Sum the cost of the selected ingredients for each burger, to give total cost of burger

    thanks for the feedback and Rep.

  12. #12
    Registered User
    Join Date
    12-04-2013
    Location
    Oxford, England
    MS-Off Ver
    Excel 2000
    Posts
    93

    Re: Sum the cost of the selected ingredients for each burger, to give total cost of burger

    Thanks icestationzbra, your formulae work too. Rep points on their way.

    I now have a new version of the problem. Here is the formula as it actually is:

    =IF(OR($F2="L",$F2="D"),(SUM(IF($B2="Y",$AJ$2,IF($Q2="Y",$AJ$3+$AJ$8,IF($T2="Y",$AJ$4+$AJ$8,IF(AND($V2="Y",$W2="Y"),$AJ$5+$AJ$8,IF($Y2="Y",$AJ$6+$AJ$8,IF($Z2="Y",$AJ$7+$AJ$8,$AJ$8)))))))),"")

    I had to eliminate any "LOOKUP" functions as l didn't use the same column heading between source and destination for the Lookup operation.

    My problem is now: The formula l have given only returns the value for the first correct "IF" expression. However, l need to sum all correct "IF" expressions. There may be multiple correct ones in the same row (Row #2 in this example). Is there any way to do it given the above formula?

    As you can probably tell, the cells which the IF statements refer to are not in a continuous row, so l cannot use a semicolon for the cells that are along Row #2. Column AJ (the vertical line of values) is fine to use a semicolon, that line is unbroken, but Row 2 is not.

    I have included a new example of what l am now actually working with. As you can see, it gets really tricky now.
    Attached Files Attached Files
    Last edited by CatSqueezer; 03-23-2014 at 07:08 AM. Reason: Added example spreadsheet

+ 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. The Repeating Cheese burger Code
    By ScoGeosan in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-16-2012, 11:34 AM
  2. Calculating total cost from range of cell tally's by cost of item.
    By patrickdjames in forum Excel Formulas & Functions
    Replies: 17
    Last Post: 11-04-2012, 10:27 AM
  3. [SOLVED] Duration of phone call and total cost.....how to work ut cost per minute ?l
    By monkeyman90210 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-23-2012, 04:18 AM
  4. [SOLVED] Outputing engineering cost based on total cost of project. Looking for help with matching
    By cadamhill in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 08-17-2012, 09:31 PM
  5. Replies: 3
    Last Post: 03-16-2010, 01:26 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