User Guide Getting Started Help Center Documentation Community Training
Looker
  
English
日本語
pivot_index Function

Back to Functions and Operators

The pivot_index function can be used in table calculations to get the value of a pivoted column based on its index.

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.

Top