Stay organized with collections
Save and categorize content based on your preferences.
The pivot_where function can be used in a table calculation to select a pivot column by a condition.
Syntax
pivot_where(select_expression, expression)
The pivot_where function returns the value of expression for the pivot column which uniquely
satisfies select_expression or null if such a column does not exist or is not unique.
Examples
In the following example we look for the pivot column that is based on "Order Status", and has a value of "pending". If we find it, return the "Order Count" in that cell:
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-14 UTC."],[],[],null,["# pivot_where Function\n\nThe `pivot_where` function can be used in a [table calculation](/looker/docs/2512/table-calculations) to select a pivot column by a condition.\n\nSyntax\n------\n\n**`pivot_where(select_expression, expression)`**\n\nThe `pivot_where` function returns the value of `expression` for the pivot column which uniquely\nsatisfies `select_expression` or `null` if such a column does not exist or is not unique.\n\nExamples\n--------\n\nIn the following example we look for the pivot column that is based on \"Order Status\", and has a value of \"pending\". If we find it, return the \"Order Count\" in that cell: \n\n pivot_where(${orders.status} = \"pending\", ${orders.count})\n\nThings to know\n--------------\n\n1. If there is *exactly* one pivot column where `select_expression` is true, the `expression` is returned. Otherwise the `expression` returns NULL.\n\n2. `pivot_where` cannot be used in a [custom filter](/looker/docs/2512/filtering-and-limiting#custom-filters)."]]