Table calculations enable you to create calculations that operate on the table data returned by a SQL query. This is great for calculating metrics like percent of totals. This post shows how to create a percent of total down a column.

You can also create percent of totals across rows.

## Using `sum()`

to calculate percent of total

In order to create a percent of total, you can utilize the `sum()`

function. This will add up all the values in a column. You can then divide each value in that column by the sum. This would look something like:

```
${orders.count} / sum(${orders.count})
```

This will give you the percent of total each value is of the column. This will something like:

Using **Value Format:** `#0.0%`

will format these values nicely for you. Read more about value format here.

## Using Look totals to calculate percent of total

As of version 3.24, it is also possible to reference Look totals in table calculations. These can be turned on in a Look by checking the **Totals** box:

Note that these totals are calculated in the SQL, so they may provide different results than the

`sum()`

function in table calculations. Read more about why this is here.

In order to calculate a percent of total using these totals, you can create a calculation like so:

```
${orders.count} / ${orders.count:total}
```

This will look something like: