Hi Kaliber,
What you are attempting to write is a set of nested IFs.
Your pop-up menu has three items: Item A, Item B, Item C.
(I use letters rather than numbers here to visually distinguish between the choices and the results.)
The syntax for IF is: IF(if-test,if-true,if-false)
if-test may be any expression that returns a boolean result, either TRUE or FALSE.
if-true tells Numbers what to do if the expression returns TRUE
if-false tells the formula what to do if the expression retruns false.
In your case, the first IF tests if the first item in the pop-up menu has been chosen.
If that expression returns TRUE, then the if-true part returns the value 100, and the formula is exited.
If that expression returns FALSE, the next value is tested for by the second IF.
Here's what it looks like. The Pop-up menu is in cell A2, the nested IFs formula is in B2, and "the formula" (named in your question) is in C2:
B2: IF(A2="Item A",100,IF(A2="Item B",50,IF(A2="Item C",220,0)))
C2: 1000-B2
Regarding the "etc., etc… part:
Although you could continue with additional nested IFs, each included as the if-false part of the previous IF, this soon be comes cumbersome, prone to error, as difficult to troubleshoot. For me, three is pretty much the limit. Beyond that (and even for a three item example), I'd turn to a lookup table and either VLOOKUP or a team effort by MATCH and INDEX to do the job.
Here's the same example, this time using VLOOKUP, and adding three 'etc.s' to the menus:
The formula shown below the tables is entered in the selected cell (C2) of the "Main" table, and filled down to the end of that table.
The popup menu cells were created by this process:
- Enter the menu choices, one per row, n the order you want them to appear in the menu, in column A of the lookup table, "minus"
- Select the cells containing the menu items list (minus::A2-A7).
- Click the Format brush to open the Format Inspector, then choose Cell.
- Use the Data Format pop-upmeu in the inspector to change the cells' data format to Pop-up menu.
Each of the selected cells, A2-A7 in the table 'minus' is now a pop-up menu, containing the list of menu items in those cells.
- Select cell A2 (one click), then chence the pop-up menu below the item list in the Inspector from 'Start with first item' to 'start with blank'.
- Set the pop-up menu in A2 to 'none' (which displays as a blank), then Copy (command-C)
- After copying, set cell A2's menu back to 'Item 1'
Now, move to the Main table.
- Click once on cell A2 of Main to select it.
- Shift-click on the last cell in column a to add it and all cells between it and cell A2 to the selection. Paste (command-V)
Each cell in the selection now contains a copy of the pop-up menu. All the cells are set to 'none'.
Column B:
Enter the formula below in B2, then fill it down to the last row of column B.
B2: IF(LEN(A2)<1,0,VLOOKUP(A2,minus::A:B,2,FALSE))
The part shown in bold is the core formula that looks up the chosen Item value in column A of 'minus' and returns the corresponding value from column B (column 2) of the same table. The FALSE argument at the end tells VLOOKUP to accept only an exact match between the menu choice and the list in column A of 'minus'.
The IF part of the formula returns a zero if no choice has yet been made (or if 'none' has been chosen) in that row's pop-up menu in column A. If any item (other than 'none' has been chosen, the LENgth of that item will be 1 or more characters, the if-test will retrun FALSE, and IF will call the core formula to do the lookup on that value.
To add more 'etc.s', you need only add more items to the pop-up menus, and to the list in column A of 'minus', and add the corresponding values to column B of 'minus'.
Regards,
Barry