---
updatedAt: 2025-12-05T18:41:41.000Z
agentTools:
  projectIndex: https://docs.observeinc.com/llms.txt
---

# pivot_array

Aliases: `array_pivot` (deprecated).

```
pivot_array(array: array, keyFieldName: string, valueFieldName: string) -> object
```

Converts an array of "key"-"value" pairs into an object with key-value attributes.

# Domain

This is a scalar function (calculates a single output value for a single input row).

# Categories

* [Semistructured](function#semistructured-functions)
* [String](function#string-functions)

# Examples

<OpalCodeBlock code={
`pivot_array(array(FIELD.foo), "key", "value")
`}/>

Converts `[{"key": "k1", "value": "v1"} {"key": "k2", "value": "v2"}, ...]` in column values to `{"k1": "v1", "k2": "v2", ...}`.