# Pivots and charts on reports

Data explorer reports and many of Breww's pre-built reports have three tabs above their results: **Table**, **Pivot** and **Chart**. Pivot and Chart let you slice the report's rows any way you like, without changing the report itself.

## Which reports have Pivot and Chart

Every [Data explorer report](https://breww.com/docs/aggregate-and-raw-data-explorer-reports/) has them, and so do many pre-built reports across sales, production, stock and deliveries, such as **All sales**, **Margin by invoice**, **Batch efficiency**, **Beer loss**, **Product movements** and **Containers delivered by date**. A pre-built report that has them shows the tabs above its results.

A few reports show the tabs only when each row is one record. For example, **Beer loss**, **Total volume packaged**, **Vessel utilisation** and **COGS by cost type** need a **Group by** that gives one loss, packaging, occupancy or batch per row, and say so when they don't.

## Preparing the data

The first time you open Pivot or Chart, Breww gathers the report's rows in the background and shows its progress. This usually takes under a minute. You can keep using the Table tab while you wait. Once it's ready, a line above the layout says how many rows are being analysed and when they were gathered. Select **Refresh data** to gather them again.

## Building a pivot

The fields from the report are listed on the left. Drag them into the zones, or use a field's **Add to layout** button:

- **Rows** and **Columns**: what to break the figures down by. A date can be grouped by year, quarter, month, week, day or day of the week.
- **Values**: the figures to show, and how to combine each one, such as Sum, Average, Minimum, Maximum, Count or Count distinct. A field can go into Values more than once, combined a different way each time.
- **Filters**: limit the pivot to some values of a field. This zone is only on pre-built reports; a Data explorer report is filtered by its own filter.

**Start from** offers ready-made layouts. Pre-built reports have their own, and a Data explorer report gets layouts Breww suggests from its data, listed under **Suggested**. Choose **New pivot** to start from nothing.

The display options above the pivot include:

- **Heat-map shading**, which shades each figure by its size.
- **Show totals**, for subtotals and grand totals.
- **Show top** and **Ranked by**, to keep only the top few of the outermost row groups, such as your top 10 customers, ranked by the value you choose. Every total and comparison then covers only those rows, and a note says what was kept, such as "Showing the top 10 of 1,240 (Customer) by Sum of Total value."

Click a column header to sort by it. Sorting only reorders the rows you're keeping, so it never changes which ones make the top 10. Collapse a group with the arrow beside it.

Percentages, unit prices and other rates can be averaged but never summed, because adding them up would give the wrong answer. The tooltip on the option explains why.

Select **Hide layout** to give the whole width to the pivot, and **Edit layout** to bring the fields back.

## Building a chart

The Chart tab works the same way, with an **X axis**, **Series (colour)** to split the chart into one line or bar per value, and **Values**. Choose a **Chart type**, such as **Bar**, **Line**, **Area**, **Pie** or **Bar and line**.

- Each value can go on the **Right-hand axis**, for example to show an order count beside sales value. Left on automatic, a value in a second unit goes on the right.
- **One line in total** draws a value as a single line rather than one per series, such as "sales value by customer, plus the total number of invoices".
- A chart over dates shows every period in the range, so a line doesn't skip a month with no data. A sum or count shows zero there; an average, minimum or maximum leaves a gap.
- A chart split by more than 20 values draws the 20 largest and combines the rest as **Other**, with a note under the chart.
- **Show top** works on charts too. It limits the x axis, or the series when the x axis is a date.

## Comparing with another period

When a report is compared with the previous period or the same period last year, the pivot shows the comparison figure and the change beside every value, totals included. Charts draw the comparison period as a dashed line or paler bars. Stacked bar, pie, doughnut and scatter charts can't show a comparison. See [Reporting periods and comparisons](https://breww.com/docs/reporting-periods-and-comparisons/).

## Exporting

Use the **Export** menu above the results:

| Tab   | Options                                                                                              |
| ----- | ---------------------------------------------------------------------------------------------------- |
| Pivot | **Export pivot to Excel**, **Export pivot to CSV**, **Export pivot to PDF**, **Export pivot to PNG** |
| Chart | **Download chart as PNG**, **Download chart as PDF**                                                 |

- The **PNG** is just the pivot or chart on a white background, ready to drop into a slide. A pivot PNG shows up to 40 rows.
- The **PDF** is a landscape page with your logo, the report's name, the period, what it's compared with, the filters in plain words, and the date the data was gathered, followed by the pivot or chart and its notes. A chart PDF is one page. A pivot PDF is up to five pages, and says how many rows are left out if it doesn't fit.
- The PDF and PNG leave out any groups you've collapsed on screen, so collapsing groups is how you make a long pivot fit. Excel and CSV always include every row.

## Saving a pivot or chart

Use **Save** while the pivot or chart is on screen, and the saved report opens on that tab with the same layout. Each run keeps the layout, and if a field is no longer in the data it's marked, with the reason in its tooltip. See [Building your own reports in the Data explorer](https://breww.com/docs/aggregate-and-raw-data-explorer-reports/) for saving and sharing, and [Automatically emailing reports on a schedule](https://breww.com/docs/scheduled-report-emails/) for emailing a pivot or chart.
