# Computed Columns

Provide additional insights by using simple formulas

Main benefits

1.

Calculate values inside Datawrapper

2.

## Show comparisons to the user

What is the ratio, what is the average?

3.

## Use simple formulas

It's even easier than in Excel

"Computed Columns" in Datawrapper

In Datawrapper 1.10 (November 2015) we introduced a powerful new feature that allows adding “computed columns” to datasets. "Computed" means that the values of new column are calculated from other values using a formula, similar to how you add columns in Excel. This type of columns can be used to provide additional comparison and depth to a chart or map. This posts explains how to use this feature.

### Example

Calculate the gender ratio for German parties

To begin with, let’s take a look at a simple dataset. We have the number of members of the German Bundestag by gender (columns), for each of the five parties (rows). Now how about adding a new column that contains the percentage of women for each party?

Step-by-step

After clicking the button labeled “Add computed columns…”, a popup window appears. Initially there are no computed columns, but you can add one using the link in the first section (below "Select/add column").

Next you enter the column name, for instance “Gender ratio“. This will be the name the column appears as in the data table and in column selector drop-downs in the chart editor. You can use any character, but you cannot use a column name that already exists in the dataset.

Finally, you can enter the formula. You can refer to the values in other columns via their column name. Start by typing the first character of the column you want to address and then hit the Tab key to auto-complete. In case there are multiple columns starting with that letter you can either enter more characters or select the column from a little popup window.

While you are typing the formula, a little display in the sidebar will show you how the first five computed values do look like. To compute the gender ratio for this example, we type the formula “women / (men + women)“.

You can use access basic mathematic functions such as round and column aggregates (sum, median etc). Please see below for a complete list.

When you’re done with the formula, hit the “Close” button to get out of the popup window. You will now see the new column in the data table view, and you can use it in all visualizations just like the other columns. To edit the formula or add more computed columns, simply click the “Add computed column…” button again.

These are all the functions you can use in your formula

On top of that you can append the following suffixes to any numeric column name to get aggregated values from entire columns:

And, if that’s not enough, you can also use anything provided by JavaScripts built-in Math object and d3.js.

Summary

Computed columns allow for additional insights in your chart or map. Be creative, take a hard look at the data you have at hand and think about how to enhance the story you tell by adding computed columns.

Other Interesting Tutorials

### How to create a Stacked Column Chart

Learn how to create a stacked column chart in minutes with Datawrapper.

### All-new line charts

Datawrapper has completely revamped line charts: More responsive, cleaner and with annotations.