I don't think there is a single formula that will do what you want but a pair of macro functions can do the job easily.

The first macro function (e.g., Quantity_Cost) is a subroutine that accepts a food name as a string and a quantity as an integer. It looks up the item price in for that name in Menu Costs, multiplies that value by the quantity, and returns the product to the calling macro.

The second macro function (e.g., Total_Cost) is the main routine. It extracts the text in the corresponding cell in the Food Option column. It determines if this text represents a single Food (as in rows 1, 2, and 3 of your sample) or it represents several Foods, each enclosed in quotes, and the entire list enclosed in brackets (as in row 5)

  • For a single Food, call Quantity_Cost passing the text and the quantity (not shown in your sample). Return the value from this call to the cell from which Total_Cost was called (the Cost column in your sample).
  • For multiple foods, you need a loop.
    • Find the first quote and note its location. If none, exit the loop.
      • Find the next quote and note its location. If none, the data is malformed.
        • Extract the text between, but not including, the quotes.
          • Call Quantity_Cost passing the extracted text and the quantity.
            • Add the value returned from this call to an accumulator.
              • Repeat the loop
  • Return the value in the accumulator to the cell from which Total_Cost was called.

You can add additional error checking as you wish. For example: check for both brackets; check for a comma between quoted foods; verify the Food exists in Menu Costs; etc.

Answer from Barry Schwarz on learn.microsoft.com
Top answer
1 of 1
1

I don't think there is a single formula that will do what you want but a pair of macro functions can do the job easily.

The first macro function (e.g., Quantity_Cost) is a subroutine that accepts a food name as a string and a quantity as an integer. It looks up the item price in for that name in Menu Costs, multiplies that value by the quantity, and returns the product to the calling macro.

The second macro function (e.g., Total_Cost) is the main routine. It extracts the text in the corresponding cell in the Food Option column. It determines if this text represents a single Food (as in rows 1, 2, and 3 of your sample) or it represents several Foods, each enclosed in quotes, and the entire list enclosed in brackets (as in row 5)

  • For a single Food, call Quantity_Cost passing the text and the quantity (not shown in your sample). Return the value from this call to the cell from which Total_Cost was called (the Cost column in your sample).
  • For multiple foods, you need a loop.
    • Find the first quote and note its location. If none, exit the loop.
      • Find the next quote and note its location. If none, the data is malformed.
        • Extract the text between, but not including, the quotes.
          • Call Quantity_Cost passing the extracted text and the quantity.
            • Add the value returned from this call to an accumulator.
              • Repeat the loop
  • Return the value in the accumulator to the cell from which Total_Cost was called.

You can add additional error checking as you wish. For example: check for both brackets; check for a comma between quoted foods; verify the Food exists in Menu Costs; etc.

🌐
Excel Tip
exceltip.com › home › summing
Summing Total Sales, Based on Quantity & Price
August 2, 2013 - Problem: Calculating the total sales price of all the items listed in column A, based on the amount of items sold (column B), and the price per unit (column C). Solution 1: Use the SUMPRODUCT function as shown in the … Continue reading →
🌐
Microsoft Support
support.microsoft.com › en-us › office › use-excel-as-your-calculator-a1abc057-ed11-443a-a635-68216555ad0a
Use Excel as your calculator - Microsoft Support
All formula entries begin with an equal sign (=). For simple formulas, simply type the equal sign followed by the numeric values that you want to calculate and the math operators that you want to use — the plus sign (+) to add, the minus sign (-) to subtract, the asterisk (*) to multiply, ...
🌐
YouTube
youtube.com › watch
How to calculate total price for products in MS Excel 2019 | Sumproduct formula - YouTube
Raw data for excel practice download : https://drive.google.com/open?id=1Lc7bYs3tepwufpeeAa50fAUFItq_JEG8This excel tutorial video shows you how to calculat...
Published   June 9, 2019
🌐
3Pie Analytics
3pieanalytics.com › excel-and-google-sheets-formulas-and-example › sum-total-sales-based-on-quantity-and-price-in-excel-or-google-sheets
sum total sales based on quantity & price in Excel and Google Sheets
Check below for a detailed explanation with pictures and how to use formulas in Excel and Google Sheets. How to sum total sales based on quantity & price in Excel?
🌐
Quora
quora.com › How-can-I-calculate-the-total-cost-of-quantity-with-price-breaks-in-Excel
How to calculate the total cost of quantity with price breaks in Excel - Quora
Answer (1 of 5): Put the Quantity and price breaks in columns A & B as follows: Qty Price 1 20 11 18 20 16 50 13 101 12 To get the unit price for the requested quantity use the formula =VLOOKUP(D3,$A$1:$B$6,2,TRUE) where D3 is the cell to the ...
🌐
MyExcelOnline
myexcelonline.com › home › how to calculate per unit price fast in excel – step by step guide
How to Calculate Per Unit Price Fast in Excel - Step by Step Guide | MyExcelOnline
January 11, 2025 - To multiply quantity and unit price in Excel, use =Quantity Cell * Unit Price Cell. This formula will give the total price for the items. This function can be dragged down to calculate for multiple entries.
🌐
YouTube
youtube.com › smart office
Calculate Value of Products from Multiple Pricing Condition - Useful Excel Trick - YouTube
Learn how to calculate the value of products when there is multiple pricing categories for the different order and quantity volumes. #advanceexcel #excelformula
Published   January 15, 2023
Views   22K
🌐
YouTube
youtube.com › yes excel
How to Calculate Total Product Price in Excel - YouTube
How to calculate total product price in Excel: In this comprehensive tutorial, we delve into the details of using Microsoft Excel to calculate the total prod...
Published   November 27, 2023
Views   170
Find elsewhere
🌐
YouTube
youtube.com › contextures inc.
Find Product Price for Quantity with Excel VLOOKUP - YouTube
✅ Get the sample Excel file to follow along ► https://myctx.link/VLOOKUP🔵 Find product price with VLOOKUP and MATCH, based on product name, and quantity ord...
Published   June 14, 2022
Views   9K
🌐
Cpearson
cpearson.com › excel › pricing.htm
Allocated Pricing
This page describes formulas for Excel to work with allocated pricing amounts.
🌐
Techwalla
techwalla.com › tech support › how to
How to Multiply the Quantity to Get a Price in Excel | Techwalla
May 6, 2011 - Enter the quantity purchased in cell B1. ... Enter the unit price in cell B2. Type "=B1*B2" in cell B3. ... Techwalla may earn compensation through affiliate links in this story. Learn more about our affiliate and product review process here.
🌐
YouTube
youtube.com › watch
How To Create Formulas in Excel to Calculate Costs - YouTube
Let's look at how to create formulas in excel to calculate costs. Create a simple formula can save you a lot of time in excel. We will look at a simple examp...
Published   August 21, 2019
🌐
Reddit
reddit.com › r/excel › formula to calculate the unit cost that changes based on the quantity purchased
r/excel on Reddit: Formula to calculate the unit cost that changes based on the quantity purchased
January 16, 2025 -

We sell a product that has a unit price that decreases as the volume purchased increases and want to add an "unlimited" price that's based on a specific volume.

Currently, the volume increments are 0-40k, 40k-70k, 70k-100k, 100k-1M, and above 1M in column A and each increment has a unit price in column B.

I want to change that last increment to 1M-6M and add a row for 6M+ but use the specific word "unlimited" in column A.

Today, the formula to calculate the cost is: =IF(B14>A6, A3*B3+(A4-A3)*B4+(A5-A4)*B5+(A6-A5)*B6+(B14-A7)*B7, IF(B14>A5, A3*B3+(A4-A3)*B4+(A5-A4)*B5+(B14-A5)*B6, IF(B14>A4, A3*B3+(A4-A3)*B4+(B14-A4)*B5, IF(B14>A3, A3*B3+(B14-A3)*B4, B14*B3))))/B14/5000

First of all, shouldn't we be using a VLOOKUP instead of that ridiculously long formula?

... and, is there a way to create a formula that looks for the word "unlimited" instead of a number to calculate a price?

Top answer
1 of 4
1
u/DIY_Carpenter456 - Your post was submitted successfully. Once your problem is solved, reply to the answer(s) saying Solution Verified to close the thread. Follow the submission rules -- particularly 1 and 2. To fix the body, click edit. To fix your title, delete and re-post. Include your Excel version and all other relevant information Failing to follow these steps may result in your post being removed without warning. I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
2 of 4
1
=IF(quantity="Unlimited,Unlimited Price*Quantity,old formula) The issue with Vlookup is that you don't have a one to one mapping, by my understanding - you have quantities that can be anything e.g. 40001, 40530, 50723 and so on, and vlookup doesn't exactly allow for matching without some intervening clause anyway. The real improvement there though is using IFS, with the highest non-unlimited quantity first and then going down the line as required. The other thing you could work out is what the actual discount is, then you only need to apply that to the final value based on the quantity, which would be easier than the various sums you have going on above, unless you're actually provide separate line entries based on the volume tiers i.e. if you have separate invoice lines for 0-40, 40-70 etc. If the net discount for unlimited amounts to... 20% say, you can just check against the quantity and apply that.
🌐
Excel Forum
excelforum.com › excel-formulas-and-functions › 1371515-formula-to-calculate-a-price-based-on-quantity-thresholds-matrix.html
Formula to calculate a price based on quantity thresholds matrix [SOLVED]
Welcome to the forum. In B3 copied across and down: =IF($A3="","",INDEX($B$10:$F$13,MATCH($A3,$A$10:$A$13,0),MATCH(B$2,$B$8:$F$8,1))*B$2) ... Last edited by AliGW; 02-16-2022 at 09:27 AM. Reason: Workbook attached. ... Enthusiastic self-taught user of MS Excel who's always learning!
🌐
McPherson College
mcphs.libguides.com › excel_basics › excel_basics › formulas
Formulas - Microsoft Excel Basics - Research Guides at MCPHS University
For the first item listed below (pencils), this could be done by making the value of the total price (cell D2), the value of the unit price (held in cell C2) multiplied by the number of items ordered (held in D2). This formula would be written "=B2*C2". After hitting "Enter", the cell will ...
🌐
YouTube
youtube.com › watch
How To Calculate Cost Per Unit in Excel - YouTube
In this video I will teach you how to calcuate cost per unit in Excel. Cost per unit refers to the amount of money it takes to produce one unit of your produ...
Published   September 14, 2023