pivot_index function

The pivot_index function can be used in table calculations to extract and manipulate the value of a pivoted column based on its index (in other words, its position).

Syntax

pivot_index(expression, pivot_index)

The pivot_index function evaluates expression in the context of the pivot column at the position pivot_index (1 for first pivot, 2 second pivot, etc.) The function returns null for unpivoted results.

Examples

The image below shows a query that includes the number of companies that were acquired or not acquired in each business category. We've also included a table calculation that displays the total number of companies in each category:

The formula used to achieve this is:

pivot_index(${companies.count}, 1) + pivot_index(${companies.count}, 2)

This simply adds the first pivot column to the second pivot column.

Things to know

pivot_index cannot be used in a custom filter.