As well as being used on its own, a function can be an argument in a larger formula. A formula, however, is limited by the fact that it can only do one function at a time. You need to make sure that functions are done in the right order if the formula is going to work.
To help set the order for functions in a multiple-function formula, you use parentheses within parentheses. When the formula is run, Calc does the innermost function first, then works outwards. For example, in the simple calculation =2+(5*7), Calc multiples 5 by 7 first. Only then is 2 added to the result to get 37.
The placement of functions within sets of parentheses is called nesting. Basically, nesting reduces a function that could run on its own to an argument in the formula. For example, in =2+(5*7), the formula (5*7) is nested within the larger formula of =2+(5*7). In other words, the nested function becomes an argument of another function.
This relation is more obvious when doing a calculation using a function with a name. For all purposes,
is the same formula as =2+(5*7). However, when SUM and PRODUCT are used, then the relation is clearer. The fact that the PRODUCT function comes after a semicolon and in a set of parentheses for the SUM function makes it clear that PRODUCT is an argument for SUM. In addition, the fact that the inner pair of parentheses is around (5;7) makes clear that this operation is done before the one defined by the outer pair of parentheses.
To get an idea of what nested functions can do, imagine that you are designing a self-directed learning module. During the module, students do three quizzes, and enter the results in cells A1, A2, and A3. In A4, you can create a nested formula that begins by averaging the results of the quizzes with the formula =AVERAGE(A1:A3). The formula then uses the IF function to give the student feedback that depends upon the average grade on the quizzes. The entire formula would read:
=IF(AVERAGE(A1:A3) >85; "Congratulations! You are ready to advance to the next module";
"Failed. Please review the material again. If necessary, contact your instructor for help")
Depending on the average, the student would receive the message for either congratulations or failure.
Notice that the nested formula for the average does not require its own equal sign. The one at the start of the equation is enough for both formulas.
If you are new to spreadsheets, the best way to think of functions is as a scripting language. We've used simple examples to explain more clearly, but, through nesting of functions, a Calc formula can quickly become complex.