Skip to main content

Pivot

Reshape data from long format to wide format by turning unique values from one column into new columns.

Sockets

SocketDirectionDescription
inputInputData to pivot
outputOutputPivoted (wide-format) data

How Pivot Works

Pivot takes a "tall" table and makes it "wide":

Before (long format):

RegionMetricValue
NorthSales100
NorthCosts80
SouthSales150
SouthCosts90

After pivoting (on: Metric, index: Region, values: Value, aggregate: first):

RegionSalesCosts
North10080
South15090

Configuration

OptionDefaultDescription
Pivot Column(required)Column whose unique values become new column headers
Group By(required)One or more columns that identify each row in the output
Values Column(required)Column whose values fill the new pivot columns
Aggregate FunctionfirstHow to combine values when multiple rows map to the same cell

Aggregate Functions

FunctionDescriptionNumeric Only
firstFirst value encounteredNo
lastLast value encounteredNo
sumSum of valuesYes
meanAverage of valuesYes
medianMedian of valuesYes
minMinimum valueNo
maxMaximum valueNo
lenCount of valuesNo
Blocking Operation

Pivot is always a blocking operation - it must read all data to determine the complete set of unique values for column headers.

Safety Checks

Sigilweaver Loom checks the number of unique values in the pivot column before executing:

Unique ValuesBehavior
< 100Normal execution
100 - 1,000Warning displayed
> 1,000Blocked by default (configurable via SAFETY_MAX_PIVOT_COLUMNS)

The configuration panel shows cardinality indicators (green/yellow/red) next to each column in the Pivot Column dropdown to help you choose safely.

Examples

Sales by Region and Product

Given a table with region, product, and revenue columns:

  1. Set Pivot Column to product
  2. Set Group By to region
  3. Set Values Column to revenue
  4. Set Aggregate Function to sum

Result: One row per region, one column per product, with summed revenue values.

Notes

  • A column cannot be used in multiple roles (e.g., both as Pivot Column and Group By)
  • The output schema depends on the actual data values, so it cannot be fully predicted from configuration alone
  • Use Unpivot to reverse a pivot operation
  • If your pivot column has too many unique values, consider filtering the data first