Functions Utility

Pivot

The Pivot() function arranges and aggregates a range of information into a more readable format. This typically involves creating new columns using information from rows.

Related functions: Depivot, GroupBy


Syntax:

Qx.Pivot(Range, Row Grouping, Column Grouping, [Formula], [Calculate Error Value])
  • In Excel with Quintessence add-in versions prior to 25.1, use: Pivot()
  • In the Quintessence Editor (Studio) using Quintessence language, use: Pivot()
  • In the Quintessence Editor (Studio) using Python language, use: Qx.Pivot()
 See parameter descriptions

RangeThe range of data to pivot.
Row GroupingColumns on which row aggregation occurs. Creates a new row group for each unique set in the selected column(s).
Column GroupingColumns on which column aggregation occurs. Creates a new column group for each unique set in the selected column(s).
Formulas
(optional)
The aggregation functions used to calculate the grouped output, for example:
SUM(C4) — where 4 refers to the column number (i.e., sum the values in column 4 for each grouped set).
Calculate Error Value
(optional)
The value that will be returned if the aggregation fails.

Remarks:

  • The default parameters are:
    • Formulas: No formula applied → no values.
    • Calculate Error Value: Aggregation failures will produce empty results.
  • An aggregate-type function is a utility function that performs aggregations on grouped data using Excel aggregate functions such as AVERAGE, COUNT, and SUM. Pivot() is considered an aggregate-type function.

Examples:

The examples provided below are based on fictitious data for illustrative purposes only.

> Example 1: Pivot and sum a data range


Data block (A1:C12):

SectorYearNumber
Financial Services2013400
Basic Resources2013250
Healthcare201325
Basic Resources2014300
Oil & Gas2013350
Basic Resources201435
Insurance2014800
Financial Services2013450
Insurance201375
Telecommunications2013120
Oil & Gas2013450
  • Row grouping: Sector
  • Column grouping: Year
  • Formula: Sum of Number
=Qx.Pivot(A2:C12, "C1", "C2", "sum(C3)")

Result:

20132014
Basic Resources250335
Financial Services850
Healthcare25
Insurance75800
Oil & Gas800
Telecommunications120
> Example 2: Pivot and sum a data range over multiple columns


Data block (A1:E12):

AssetSectorYearMonthNumber
JTDOil & Gas2000March620
GPSIndustrials2000June250
APNHealth Care2005June25
CFHIndustrials2005March300
PHOConsumer Goods2000June800
BVTIndustrials2005March35
ZIKHealth Care2005March800
JTDOil & Gas2000June450
VRRConsumer Goods2000June75
PHOConsumer Goods2000June480
THTConsumer Goods2000March250
  • Row grouping: Asset, Sector
  • Column grouping: Year, Month
  • Formula: Sum of Number
=Qx.Pivot(A2:E12,"C1,C2","C3,C4","SUM(C5)")

Result:

2000200020052005
JuneMarchJuneMarch
APNHealth Care25
BVTIndustrials35
CFHIndustrials300
GPSIndustrials250
JTDOil & Gas450620
PHOConsumer Goods1280
THTConsumer Goods250
VRRConsumer Goods75
ZIKHealth Care800