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

# `case_greaterthan`

## Description

Returns a value based on whether a number is greater than one of several thresholds.

This function is a shorthand for `case` expressions with `>` (greater than) logic and helps shorten queries that would otherwise repeat conditional statements. If no clause matches and no `_` fallback is present, `case_greaterthan` returns `null`.

Note

`case_greaterthan` checks clauses top-to-bottom and returns the **first match**, so order matters.

## Syntax

```
case_greaterthan {

  n: number,

  value1: number -> result1,

  value2: number -> result2,

  ...

  valueN: number -> resultN,

  _              -> default

}
```

## Arguments

| Name     | Type     | Required  | Description                                              |
| -------- | -------- | --------- | -------------------------------------------------------- |
| `n`      | `number` | **true**  | The numeric expression to compare                        |
| `value`  | `number` | **true**  | A threshold value for comparison                         |
| `result` | `any`    | **true**  | The value to return if `n` is greater than the threshold |
| `_`      | `any`    | **false** | Default value if no thresholds match                     |

## Example

**Use case: Map HTTP status codes to text descriptions**

Suppose you want to create a field `status_description` that provides a readable label for HTTP status codes. Consider these log documents:

```
{

  "status_code": 201

},

{

  "status_code": 500

},

{

  "status_code": 404

}
```

The comparison thresholds should be listed in descending order, since the first match is returned. Also note that each threshold must be reduced by 1 because `case_greaterthan` uses a strict `>` operator (not `>=`). For example, to capture 4xx codes, use `399` as the threshold, not `400`.

### Example query

```
create status_description from

case_greaterthan {

  $d.status_code,

  499 -> 'server-error',

  399 -> 'client-error',

  299 -> 'redirection',

  199 -> 'success',

  99  -> 'information',

  _   -> 'other'

}
```

### Example output

```
{

  "status_code": 201,

  "status_description": "success"

},

{

  "status_code": 500,

  "status_description": "server-error"

},

{

  "status_code": 404,

  "status_description": "client-error"

}
```
