Copy as Markdown[Open in ChatGPT](https://chatgpt.com/?q=Read%20https%3A%2F%2Fcoralogix.com%2Fdocs%2Fdataprime%2Flanguage-reference%2Ffunctions-reference%2Faggregation%2Fany_value.md%20and%20help%20me%20with%20my%20question%20about%20this%20Coralogix%20documentation%20page.)[Open in Claude](https://claude.ai/new?q=Read%20https%3A%2F%2Fcoralogix.com%2Fdocs%2Fdataprime%2Flanguage-reference%2Ffunctions-reference%2Faggregation%2Fany_value.md%20and%20help%20me%20with%20my%20question%20about%20this%20Coralogix%20documentation%20page.)

# `any_value`

## Description

Returns any non-null value from the specified expression within a group. If no expression is provided, it defaults to the `$d` object.

Returns `null` if all values in the group are `null`.

## Syntax

```
any_value(expression: any?): any
```

## Arguments

| Name         | Type  | Required  | Description                               |
| ------------ | ----- | --------- | ----------------------------------------- |
| `expression` | `any` | **false** | Expression to evaluate. Defaults to `$d`. |

## Example

**Use case: Select any non-null username from a group of documents**

Suppose you want to group documents by team and retrieve any available username.

### Example data

```
{

    "userId": 1,

    "team": "A Team",

    "username": null

},

{

    "userId": 2,

    "team": "A Team",

    "username": "Ryan"

},

{

    "userId": 3,

    "team": "A Team",

    "username": "Anastasia"

}
```

### Example query

```
groupby team aggregate any_value(username) as random_username
```

### Example output

The output may vary depending on the order in which documents are processed:

```
{

"team": "A Team",

"random_username": "Ryan"

}
```
