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

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

```json
{
  "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

```dataprime
create status_description from
case_greaterthan {
  $d.status_code,
  499 -> 'server-error',
  399 -> 'client-error',
  299 -> 'redirection',
  199 -> 'success',
  99  -> 'information',
  _   -> 'other'
}
```

### Example output

```json
{
  "status_code": 201,
  "status_description": "success"
},
{
  "status_code": 500,
  "status_description": "server-error"
},
{
  "status_code": 404,
  "status_description": "client-error"
}
```
