# `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

```dataprime
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

```json
{
    "userId": 1,
    "team": "A Team",
    "username": null
},
{
    "userId": 2,
    "team": "A Team",
    "username": "Ryan"
},
{
    "userId": 3,
    "team": "A Team",
    "username": "Anastasia"
}
```

### Example query

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

### Example output

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

```json
{
"team": "A Team",
"random_username": "Ryan"
}
```
