Numbers - Nutrition Input Help

Hi, Apple Community! I need some help with Numbers regarding the input of my nutritional data. Here's what I'm working on:


These are the nutrition facts of some bread I made. But I would like the values of the Calories, Fat, Carbohydrates, and Protein to change correspondingly when I input a different Amount of the Ingredient in grams.


For example, if I were to change the Amount (g) of Dry Yeast from 4 to 10g, I would like the corresponding Calories, Fat, Carbs, and Protein to change accordingly.


I have no idea if this is even possible with spreadsheets, but I have this idea in my mind that if I could only "teach" the cells the values of 100g of each Ingredient, I could somehow get Numbers to do the math and automatically change those values to reflect other gram amounts. If this is possible, how could I pull this off?


Ideally, I could also have a whole list of Ingredients on another Table, each with the standard values for 100g, and then I could just copy and paste each ingredient into whatever Nutrition Facts Table I'm making and simply change the Amount — or better yet, instead of laboriously copying and pasting, it'd be great if I could just start typing the name of the Ingredient from another table, and Numbers would just autofill the rest of the values. I know Numbers autofills single cells, but is there a way to get it to also do the rest of the row values?


I apologize for this plethora of questions. I admit Numbers and spreadsheets in general are still relatively new to me. I'd sincerely appreciate any help I can get! Thanks, everyone!

Posted on Mar 31, 2019 6:31 PM

Reply
Question marked as Top-ranking reply

Posted on Mar 31, 2019 8:15 PM

Hi Tai-kun,


You've thought it out well, and have arrived at the most likely solution—a Lookup table to store the basic data, and a calculation to produce the actual results.


Here's what it might look like in Numbers.

The upper table (Table 1) is the lookup table. The data in columns B through E were back-calculated from the figures in your recipe, then pasted into the lookup table as fixed values. Each is the amount for 100g of the named ingredient.


The lower table (Table 2) is the recipe table shown in your post. The Ingredients list and amount columns contain entered data, as does Row 1. All other values in the xample are calculated using the VLOOKUP formula shown below the tables The formula is entered in cell C2 of Table 2, then filed right to column F and down to row 9. (I went to row 10 to show the error triangles that are generated when VLOOKUP is told to look for the contents of an empty cell.


I haven't included the bottom two rows as you've already got the formulas for those.


If you want to include extra ingredient rows in the table, you can avoid the error triangles by wrapping the formula in an IF statement that acts as a switch, preventing VLOOKUP from searching when there's an empty cell in column A, and nothing to search for:


Existing:

C2: VLOOKUP($A2,Table 1::$A:$E,COLUMN()−1)×$B2÷100


Revised: IF(LEN(A2)<1,"",VLOOKUP($A2,Table 1::$A:$E,COLUMN()−1)×$B2÷100))


The part in bold is the original formula. The added part is in normal type weight.


Regard,

Barry




Similar questions

10 replies
Question marked as Top-ranking reply

Mar 31, 2019 8:15 PM in response to Tai-kun

Hi Tai-kun,


You've thought it out well, and have arrived at the most likely solution—a Lookup table to store the basic data, and a calculation to produce the actual results.


Here's what it might look like in Numbers.

The upper table (Table 1) is the lookup table. The data in columns B through E were back-calculated from the figures in your recipe, then pasted into the lookup table as fixed values. Each is the amount for 100g of the named ingredient.


The lower table (Table 2) is the recipe table shown in your post. The Ingredients list and amount columns contain entered data, as does Row 1. All other values in the xample are calculated using the VLOOKUP formula shown below the tables The formula is entered in cell C2 of Table 2, then filed right to column F and down to row 9. (I went to row 10 to show the error triangles that are generated when VLOOKUP is told to look for the contents of an empty cell.


I haven't included the bottom two rows as you've already got the formulas for those.


If you want to include extra ingredient rows in the table, you can avoid the error triangles by wrapping the formula in an IF statement that acts as a switch, preventing VLOOKUP from searching when there's an empty cell in column A, and nothing to search for:


Existing:

C2: VLOOKUP($A2,Table 1::$A:$E,COLUMN()−1)×$B2÷100


Revised: IF(LEN(A2)<1,"",VLOOKUP($A2,Table 1::$A:$E,COLUMN()−1)×$B2÷100))


The part in bold is the original formula. The added part is in normal type weight.


Regard,

Barry




Mar 31, 2019 11:28 PM in response to Tai-kun

Typo on my part. The formula is filled right and down to place it in every cell of the range C2 to F9.


There are two ways to do this:

After entering the formula into C2:


  • Select C2 (single click)
  • Bring the mouse pointer close to the right end of C2.
  • When a yellow dot (the Fill Handle) appears on the right cell boundary, place the tip of the pointer on it, press and hold the mouse button and drag right to fill the formula into D2, E2 and F2.
  • Release the mouse button.
  • Bring the pointer close to the centre of the bottom boundary of cells C2 - F2.
  • When the Fill handle appears on that boundary, 'grab' it and drag down to fill the formulas into rows 3 to 9.
  • Release the mouse button.


Alternate method:

After entering the formula into C2:


  • Select (single click) cell C2.
  • Press command-C to Copy the cell.
  • Shift-click (press and hold the Shift key and click) cell F9

(This expands the selection to include all cells in the range C2 to F9)

  • Press command-V to paste the formula into all cells in the range.
  • Done


Regards,

Barry




Mar 31, 2019 10:05 PM in response to Barry

I am attempting to implement this formula at the moment, but I'd like to clarify one point. When you say "The formula is entered in cell C2 of Table 2, then filed right to column F and down to row 9," what does "filed" mean? Did you actually enter this formula manually into every single cell? I was kind of hoping for a more automated way of doing this so that all I'd have to do was change the Amount (g) and then all the values from columns B to E would automatically update.


Perhaps I'm just missing something and that's precisely what what you've explained does?

Apr 1, 2019 6:15 AM in response to Badunit

Column A of each of these sheets is populated by a pop up menu from which you can make selections.


When you add an item to the Food Items list, it will not automatically become part of the pop up for the other sheets. What I do after adding items is select all of column A, change the cell format to text, sort alphabetically, then change the format to pop up menu. Next, select one of the "-----" cells from column A, copy it, and paste it to all cells in column A of an unfilled "recipe" or "day' sheet (like the sheet I have that is called "BLANK"). Use that sheet as the template for future recipes/days (i.e., duplicate it when you want to make a new recipe or a new day).

Apr 1, 2019 6:09 AM in response to Tai-kun

Here is one I started


https://www.dropbox.com/s/iw920x84hj4mcmp/Nutrition%20Spreadsheet.numbers?dl=0


1) Food items: manually entered off of the labels or internet. For some I used some math to create the portion sizes I typically use (like a full can of tomatoes vs a 1/4 can serving).

2) There are a few sheets with the ingredients for recipes. I'll create them then copy the resulting nutrition data and create a food item (all the "homemade" items on my list)

3) The same sheet can be used to add up your nutrition for the day.


I would like to post more information about the popup menus in column A but I am having a lot of difficulty with the forum this morning. I will try to continue in a new post

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Numbers - Nutrition Input Help

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.