Function Problems

Build a Dynamic Recipe Nutrition and Cost Calculator in Excel

Elise WilliamsElise Williams Dec 2, 2026 868 views

Question details

Create a recipe calculator that retrieves ingredient nutrition and price values and calculates amounts based on quantity.

Build a Dynamic Recipe Nutrition and Cost Calculator in Excel
Product
Microsoft Excel
Device & OS
not provided
Scenario
A user wants a reusable recipe template that calculates nutrition and cost from an ingredient database using table references.
Observed behavior
Ingredient values should update dynamically when the selected ingredient or quantity changes.
Before you start

Gather ingredient nutrition and price data expressed per gram, and use consistent ingredient names. Check that your Excel version supports XLOOKUP; it is available in Microsoft 365 and Excel 2021 or later.

Solution 1Recommended

Use Excel Tables and XLOOKUP to calculate recipe totals

Use structured references to look up per-gram values and automatically calculate each ingredient's contribution.

1
Create the ingredient database

Enter the headers Ingredient, CaloriesPerGram, CarbsPerGram, FatPerGram, and PricePerGram above your data. Select the range, choose Insert > Table, and confirm that the table has headers. On the Table Design tab, name the table Ingredients.

2
Create the recipe table

In another range, enter the headers Ingredient, Quantity, Calories, Carbs, Fat, and Cost. Select the range, choose Insert > Table, and name it Recipe on the Table Design tab. Enter ingredient names and quantities in grams.

3
Calculate calories

In the first data row of the Calories column, enter =[@Quantity]*XLOOKUP([@Ingredient],Ingredients[Ingredient],Ingredients[CaloriesPerGram]). Excel will normally fill the formula down the table column.

4
Calculate nutrients and cost

In the Carbs column, use =[@Quantity]*XLOOKUP([@Ingredient],Ingredients[Ingredient],Ingredients[CarbsPerGram]). Repeat the pattern in Fat and Cost, replacing CarbsPerGram with FatPerGram and PricePerGram respectively.

5
Add recipe totals

Below the table or in a separate summary area, enter =SUM(Recipe[Calories]), =SUM(Recipe[Carbs]), =SUM(Recipe[Fat]), and =SUM(Recipe[Cost]) to total each column. Format the cost total as currency using Home > Number.

Use Excel Tables and XLOOKUP to calculate recipe totals
Check units and ingredient names: The formulas expect quantities in grams and database values per gram. An ingredient name that does not match the database returns an #N/A error.
Calculate recipes in WPS Spreadsheet

Create a recipe nutrition and cost calculator in WPS Spreadsheet

Use an ingredient worksheet and VLOOKUP formulas in WPS Spreadsheet to calculate nutrition and cost from ingredient quantities.

  1. 1. Set up the ingredient sheet: In WPS Spreadsheet, create a worksheet named Ingredients. In columns A through E, enter Ingredient, CaloriesPerGram, CarbsPerGram, FatPerGram, and PricePerGram, followed by your data in rows 2 through 1000.
  2. 2. Set up the recipe sheet: Create a second worksheet with Ingredient, Quantity, Calories, Carbs, Fat, and Cost in columns A through F. Enter an ingredient name in A2 and its quantity in grams in B2.
  3. 3. Add lookup formulas: In C2, enter =B2*VLOOKUP(A2,Ingredients!$A$2:$E$1000,2,FALSE). Copy the formula into D2, E2, and F2, changing the column index from 2 to 3, 4, and 5 respectively. Copy the formulas down for additional ingredients.
  4. 4. Total the recipe: Below the recipe rows, use SUM formulas such as =SUM(C2:C10) for calories and =SUM(F2:F10) for cost. Adjust the ranges to include all ingredient rows.
Calculate calories, carbohydrates, fat, and cost by ingredientOpen and save Microsoft Excel XLSX filesUse familiar spreadsheet formulas and worksheetsWork with a free, easy-to-use office suite
microsoft office alternative - wps office

Frequently Asked Questions

Why does my ingredient formula return #N/A?

XLOOKUP returns #N/A when it cannot find the ingredient. Check that the name in Recipe[Ingredient] matches an entry in Ingredients[Ingredient] and that the database table includes the ingredient row.

How do I calculate values per serving?

Enter the number of servings in a separate cell, such as B2, and divide each recipe total by it. For example, use =SUM(Recipe[Calories])/B2 for calories per serving.

Can I use this calculator without XLOOKUP?

Yes. Use VLOOKUP with the ingredient name in the first column of the database range. For example, =B2*VLOOKUP(A2,Ingredients!$A$2:$E$1000,2,FALSE) returns calories for a quantity in grams.

Will the formulas include new ingredients added to the Excel database table?

Yes. Add the ingredient directly below or inside the Ingredients table so Excel expands it. Structured references such as Ingredients[Ingredient] then include the new row.