Skip to content
Learn › Clean and shape data: open the docs menu

Group, pivot and unpivot data

All plans · Project Editor or Project Admin · Updated 8 Nov 2026

Group & Pivot summarises rows by one or more columns, like a spreadsheet pivot table, and Unpivot turns wide columns into rows. Open them from the Describe your transformation box (or a + button in the Pipeline panel) and select Reshape, Group & Pivot. Both are pipeline tasks that run again every time the pipeline refreshes.

Group and pivot step by step

Describe your transformation menu on Reshape, Group & Pivot, with Group & Pivot first

Step 1 of 6: Open Group & Pivot

What Rows, Columns and Values do

FieldWhat it does
RowsThe columns you group by. Each unique combination of their values becomes one row.
ColumnsA column whose unique values become separate column headers. This makes pivot output. Leave it empty for a plain grouped summary.
ValuesThe columns to calculate for each group

What you can calculate in Values

Column in ValuesWhat it calculates
NumberPick an aggregation from the menu under the value: Sum, Average, Min, Max or Standard Deviation
TextJoins the group's values into one list, separated by a comma by default. Only while Columns is empty.
Same number column twiceAdd it again for a second aggregation, for example Sum and Average side by side
+ CountA row count for each group. You can add it once. Shown while no column is ticked.
+ Distinct countThe number of distinct values of a text or ID column in each group. Only while Columns is empty ("Available when "Columns" section is empty").

Date columns can go in Rows or Columns, but not in Values. While a text value or a distinct count is in Values, the Columns field is turned off.

Build a pivot table with values as column headers

Add a column to Columns. Each of its unique values becomes a column header, with the Values calculation under it.

Example: put product_name in Rows, promotion_code in Columns and quantity_sold in Values with Sum. You get one row per product and one column per promotion code.

Join text values into one list per group

Add a text column to Values. Each group gets one cell with the group's values joined together.

Example: group orders by customer_id and drop product_name into Values. Set Delimiter to ; and Display Name to products_bought. Each customer gets one row with a list such as "Mug; Teapot; Kettle".

Rename a result column, set its number format or delimiter

Each chip in Values has an edit icon. Click it to open the Edit menu, change the settings and click Save changes.

OptionShown forWhat it does
Display NameEvery value, while the result stays in this ViewNames the result column. The default reads like "SUM of quantity_sold".
Edit formatNumber values and countsSets the number format: separators, decimal places, currency symbol or percentage
DelimiterText valuesThe characters placed between joined values. The default is a comma.

Number columns in Rows have the same edit icon, with Display Name and Edit format.

Group dates by year, month, weekday or hour

When a date column is in Rows or Columns, its edit icon opens an Edit format list that sets how dates are grouped. The default is by day (DD-Mon-YYYY).

Edit formatGroups byResult column type
DD Mon, YYYY HH:MM:SSSecondDate
DD Mon, YYYY HH:MMMinuteDate
DD Mon, YYYY HHHourDate
DD-Mon-YYYY (default)DayDate
YYYY, MonthYear and monthText
YYYY (number icon)YearNumber
MonthMonth name, across all yearsText
YYYY (text icon)YearText
WeekdayDay of the week, across all weeksText
Mon-DD, YYYY HH:MM:SSSecond, written as textText

A format that isn't a date changes the column's type. The menu tells you before you save, for example: "Editing format of column "order_date", changes its type from "Date" to "Text"". A date column in Rows also has a Display Name box.

Example: to total sales by month, put order_date in Rows, set its Edit format to YYYY, Month, and put sales in Values with Sum.

Preview the grouped result before you apply

The live preview shows the grouped result above the panel while you set it up. Use the Preview control in the panel header to turn it off or on. See How the pipeline works for the preview tabs and controls.

Group & Pivot Preview modal above the panel, showing a pivoted preview table

Send the result to a new dataset instead of this View

By default the result replaces the rows of the current View (Place the result in this View). To keep this View as it is, choose New Dataset, give it a name and pick where it goes under Located at.

Turn columns into rows with Unpivot

Unpivot turns a wide table into a long one: column headers become row values. Use it when you have one column per period or category, such as Jan_Sales, Feb_Sales and Mar_Sales, and need one Month column and one Sales column. Most grouping, joining and analysis works best on the long layout.

Unpivot panel with Dimensions and Name columns selected, label column title Product, value column title Size, and an example
  1. In your View, click Describe your transformation, then Reshape, Group & Pivot › Unpivot.
  2. In Select columns to be transposed, pick the columns to turn into rows. Once you pick one, only columns of the same type are offered.
  3. In "Label" column title, name the new column that will hold the old column headers.
  4. In "Value" column title, name the new column that will hold the old cell values.
  5. If the columns are numbers or dates, set Format. For numbers, set the number format of the value column. For dates, click Choose date format and pick one.
  6. Click Apply.

All other columns are kept and repeated on each new row. The two new names must differ from each other and from existing columns.

Example: a View has store, Jan_Sales, Feb_Sales and Mar_Sales. Select the three sales columns, name the label column Month and the value column Sales, and click Apply. Each store now has three rows, one per month.

Troubleshooting

SymptomCauseFix
"Adding or averaging it adds up the codes. Did you mean Count distinct?"Sum or Average on a column marked as an IDClick Swap to Count distinct, or Keep to leave it
"Adding percentages rarely means anything. Did you mean Average?"Sum on a Percentage columnClick Swap to Average, or Keep to leave it
The Columns field is turned offA text value or a distinct count is in ValuesRemove it to pivot
A ticked column doesn't arrive in ValuesDates never go in Values; text only goes in while Columns is emptyUse + Count, extract a number from the date first, or empty Columns
Sum or Average isn't offeredThe column is text, not NumberAdd a Convert Column Type step before Group & Pivot. See Convert text to dates and numbers.
An empty group appearsThe grouping column has empty valuesFilter those rows out first, or handle the group later
"A column with same name already exists. Try another value" (Unpivot)A new column name is already usedChoose a different label or value column title
"The new value column does not carry over the meaning of the columns you stack (an ID, a currency or a percentage). It starts as a plain column." (Unpivot)The stacked columns were marked as an ID, currency or percentageAdd a Convert Column Type step after the Unpivot to restore the meaning

The column meaning warnings appear under Values and never block Apply. Once you click Keep, the warning stays dismissed for that step. See Column types, IDs, currency and percentages for how a column gets its meaning.

Was this page helpful?

Something wrong? support@mammoth.io