# Adding a Table Formula

Learn how to add formulas to tables at run time using the Formula Editor or code. Discover how to set the visibility of the total row and automatically create calculated columns.

## Content

You can add formulas to the table in a total row at run time with the **Formula Editor** or with code.
Add a total row and then select the drop-down arrow at the bottom right corner of the table to display formulas.
![Table formula example](https://cdn.mescius.io/document-site-files/images/2238e618-a1fb-45a6-9ce5-9a4157bd2931/images/tableformdrop.png)
You can select **More Functions** to display the **Formula Editor** as shown in the following figure.
![Formula Editor Dialog](https://cdn.mescius.io/document-site-files/images/2238e618-a1fb-45a6-9ce5-9a4157bd2931/images/tableformulaeditor.png)
You can add formulas to the table with the [Formula](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.Cell.Formula.html) property. For more information about using structured references in table formulas, see [Using Structured References](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-tables/spwin-structref/spwin-structuse).

## Setting Visibility of Total Row

You can use the [TotalRowVisible](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.TableView.TotalRowVisible.html) property to display the total row for the table. The following example adds a total row.

```csharp
fpSpread1.Sheets[0].Cells[1, 1].Text = "Last Name";
fpSpread1.Sheets[0].Cells[1, 2].Text = "Value";
fpSpread1.Sheets[0].Cells[2, 1].Text = "Smith";
fpSpread1.Sheets[0].Cells[2, 2].Value = 50;
fpSpread1.Sheets[0].Cells[3, 1].Text = "Vil";
fpSpread1.Sheets[0].Cells[3, 2].Value = 10;
fpSpread1.Sheets[0].Cells[4, 1].Text = "Press";
fpSpread1.Sheets[0].Cells[4, 2].Value = 78;
FarPoint.Win.Spread.TableView table = fpSpread1.Sheets[0].AddTable("table", 1, 1, 5, 2);
table.TotalRowVisible = true;
```

```vbnet
fpSpread1.Sheets(0).Cells(1, 1).Text = "Last Name"
fpSpread1.Sheets(0).Cells(1, 2).Text = "Value"
fpSpread1.Sheets(0).Cells(2, 1).Text = "Smith"
fpSpread1.Sheets(0).Cells(2, 2).Value = 50
fpSpread1.Sheets(0).Cells(3, 1).Text = "Vil"
fpSpread1.Sheets(0).Cells(3, 2).Value = 10
fpSpread1.Sheets(0).Cells(4, 1).Text = "Press"
fpSpread1.Sheets(0).Cells(4, 2).Value = 78
Dim table As FarPoint.Win.Spread.TableView = fpSpread1.Sheets(0).AddTable("table", 1, 1, 5, 2)
table.TotalRowVisible = True
```

## Automatically Create Calculated Columns

You can automatically fill a column with the entered formula in the table by using the [AutoCreateCalculatedColumns](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.IFeatures.AutoCreateCalculatedTableColumns.html) property. This property accepts a boolean value.
![](https://cdn.mescius.io/document-site-files/images/2238e618-a1fb-45a6-9ce5-9a4157bd2931/images/table-autocalccol.gif)

```csharp
fpSpread1.Sheets[0].Cells[1, 3].Text = "Sum";

fpSpread1.Features.AutoCreateCalculatedTableColumns = true;
```

```vbnet
FpSpread1.Sheets(0).Cells(1, 3).Text = "Sum"

FpSpread1.Features.AutoCreateCalculatedTableColumns = True
```

## See Also

[Formulas in Cells](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-cell-formula)
[Setting Table Properties in Spread Designer](/spreadnet/docs/latest/online-win/overview/spwin-designerguide/spwin-spd-design/spwin-spd-setprop/spwin-spd-settable)
[Tables](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-tables)
[Adding a Table](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-tables/spwin-tableadd)
[Using Table Filters](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-tables/spwin-tablefilter)
[Resizing a Table](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-tables/spwin-tableresize)
[Sorting a Table](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-tables/spwin-tablesort)
[Setting Table Styles](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-tables/spwin-tablestyle)
[Understanding Structured References](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-tables/spwin-structref)