# Nested Functions

This topic explains how to create nested functions in cells in the Spread for WPF.

## Content

Nested functions refer to a situation where one function is placed inside another function. This allows you to perform more complex calculations by combining multiple functions in a single formula. The output of one function becomes the input for another. To create a nested function in the worksheet, you can use the [Formula](/spreadnet/api/latest/online-wpf/GrapeCity.Spreadsheet/GrapeCity.Spreadsheet.IRange.Formula.html) property of the **IRange** interface, just as you would with a regular formula.
The following image illustrates how to nest the AVERAGE and SUM functions in an IF function.
![](https://cdn.mescius.io/document-site-files/images/0f63724f-fddf-4351-8c24-0b4338c0fda9/images/nested-function.png)
Refer to the following example code to nest the AVERAGE and SUM functions in an IF function.
**C#**

```csharp
// Nested function.
spreadSheet1.Workbook.ActiveSheet.Cells["E2"].Formula = "=IF(AVERAGE(B1:B4)>50,SUM(A1:A4),0)";
```

**VB**

```auto
' Nested function.
spreadSheet1.Workbook.ActiveSheet.Cells("E2").Formula = "=IF(AVERAGE(B1:B4)>50,SUM(A1:A4),0)"
```