Using Header Notation in Quintessence
In Quintessence, several functions support header notation, allowing you to reference columns by their header names rather than their positional index. This improves readability, reduces errors, and ensures formulas remain robust even when column order changes.
Functions That Support Header Notation
The following functions are compatible with header notation:
- FilterData (see Example 3)
- GroupBy (see Example 2)
- Join (see Example 2)
- Pivot (see Example 2)
- SortData (see Example 2)
- Transform (see Example 5)
Purpose of Header Notation
Header notation serves two important goals:
- Preserving original headers
When no calculations are applied, Quintessence retains the original data headers.
(ThePivotfunction is the only exception, as it does not return the original headers.) - Reliable column access
Because datasets may vary in structure or column order, referencing columns by name ensures that formulas always use the correct field – regardless of position.
How Calculated Columns Are Named
When calculations are applied using header notation, Quintessence assigns names like Header n to new output columns, where n refers to the position of that column in the result.
For example, given the data in cells A1:B4:
| Stock | Price |
| AAA | 100 |
| BBB | 200 |
| DDD | 400 |
The formula:
=Qx.Transform(A1:B4, "[Stock], 'Stock: ' + [Stock], [Price], [Price] + 1")Produces the following output:
| Stock | Header 2 | Price | Header 4 |
| AAA | Stock: AAA | 100 | 101 |
| BBB | Stock: BBB | 200 | 201 |
| DDD | Stock: DDD | 400 | 401 |
Renaming Output Headers
You can rename generated headers using the as keyword. For example, to:
- Replace Header 2 with Stock and drop the original Stock column
- Rename Price to OldPrice
- Rename Header 4 to NewPrice
You can use:
=Qx.Transform(A1:B4, "'Stock: ' + [Stock] as [Stock], [Price] as [OldPrice], [Price] + 1 as [NewPrice]")Which produces:
| Stock | OldPrice | NewPrice |
| Stock: AAA | 100 | 101 |
| Stock: BBB | 200 | 201 |
| Stock: DDD | 400 | 401 |
Conclusion
Header notation is a powerful feature in Quintessence that makes formulas more intuitive, flexible, and resilient. By referencing columns by name rather than by position, you avoid issues caused by structural changes in your data and maintain clarity in your transformations. Combined with the ability to rename output columns, header notation helps ensure that your results remain well‑structured, readable, and aligned with your analytical goals.
