- Update: 2018-03-17
- Version: VisiData 1.1

Aggregators provide summary statistics for grouped rows.

Command | Operation |
---|---|

`+` aggregator |
adds aggregator to current column |

`z+` aggregator |
displays result of aggregator over values in selected rows for current column |

The following statistical aggregators are available:

Aggregator | Description |
---|---|

`min` |
smallest value in the group |

`max` |
largest value in the group |

`avg` /`mean` |
average value of the group |

`median` |
median value in the group |

`sum` |
total summation of all numbers in the group |

`distinct` |
number of distinct values in the group |

`count` |
number of values in the group |

`keymax` |
key of the row with the largest value in the group |

The follow howtos will have examples of workflows involving grouping of data and statistical aggregation.

This example uses the file sample.tsv.

- Press
`!`

on the independent variable to set it as a key column. - Press
`+`

on a second column to add an*aggregrate*. This configures which column is to be composed in relation to others. - Optional: Set the type for the column being aggregated by pressing
`~`

(string),`#`

(int),`%`

(float),`$`

(currency), or`@`

(date). - Press
`W`

on the dependent categorical variable to pivot on it.

The following examples use the file sample.tsv.

**Question** How many of each **Item** were sold?

- Move the cursor to the
**Item**column. - Press
`F`

to open the**Frequency table**.

**Question** What was the monthly revenue?

- On the
**OrderDate**column, type`;`

followed by`(\d+-\d+)`

to create a column with only the year and the month using regex capture groups. - Press
`-`

to hide the**OrderDate**column. - On the **OrderDate_re0** column, type
`^`

followed by`OrderDate`

to rename it. - On the
**Total**column, press`$`

to set its type to currency. - Type
`+`

followed by`sum`

to add a statistical aggregator to**Total**. - On the
**OrderDate**column type`F`

to open the**Frequency table**. - On the
**OrderDate**column, press`[`

to sort the table in chrononological order. - On the **sum_Total** column, type
`^`

followed by`Revenue`

to rename the column.

- Press
`I`

to open the**Describe sheet**.

- Press
`F`

to open the**Frequency table**. - Press
`s`

or`t`

on the groups you are interested in to select those entries in the source sheet. - Press
`q`

or`Ctrl+^`

to return to the source sheet. - Press
`"`

to open a duplicate sheet with selected rows.

**or**

- Press
`F`

to open the**Frequency table**. - Press
`Enter`

on the grouping you are interested in to open a sheet of the source rows that are part of that group.

- Press
`I`

to open the**Describe sheet**. - Use
`zs`

to select rows on source sheet which are being described in the cells of interest. - Press
`q`

or`Ctrl+^`

to return to the source sheet. - Press
`"`

to open a duplicate sheet with selected rows.

**or**

- Press
`I`

to open the**Describe sheet**. - Press
`zEnter`

open copy of source sheet with rows being described in the current cell of interest.

`Enter`

/`zEnter`

can both be used in the **Pivot table** to open a sheet of the source rows which are aggregated in the current pivot row/cell.