# Less Than Check Examples

Source: https://userguide.qualytics.io/data-quality-checks/less-than/deep-dive/examples/

Three real-world scenarios that show how the Less Than check is typically used in production: enforcing a strict latency budget, capping an inclusive discount rate with a filter, and tolerating rounding noise on a computed ratio. The first two run at 100% coverage and report Record Anomalies; the third lowers coverage and reports a Shape Anomaly instead.

**Tab: Strict Latency Budget**

**The situation:** The API gateway logs a `response_ms` per request. The service level objective is a response strictly under 500 ms, so exactly 500 already breaks the budget and **Inclusive** is off.

**Check configuration**

| Field | Value |
| --- | --- |
| Rule | Less Than |
| Field | `response_ms` |
| Filter | *(none)* |
| Custom Anomaly Description | Off |
| Value | `500` |
| Inclusive | Off |
| Numeric | *(none)* |
| Coverage | 100% |
| Owner | *(check creator)* |
| Anomaly Assignee | *(Platform SRE)* |
| Description | Response time must be under the 500 ms budget. |
| Tags | `performance`, `sla` |
| Additional Metadata | `jira: DATA-8501` |
| Status | Active |

**Payload**

```json
{
    "description": "Response time must be under the 500 ms budget.",
    "rule": "lessThan",
    "fields": ["response_ms"],
    "container_id": 145,
    "coverage": 1,
    "filter": null,
    "properties": {"value": 500, "inclusive": false},
    "tags": ["performance", "sla"],
    "additional_metadata": {"jira": "DATA-8501"},
    "anomaly_message_field": null,
    "template_id": null,
    "status": "Active",
    "owner_id": 7,
    "default_anomaly_assignee_id": 12
}
```

**Sample Data**

| request_id | response_ms | route |
| --- | --- | --- |
| R-001 | 128 | /orders |
| R-002 | 500 | /orders |
| R-003 | 340 | /invoices |
| R-004 | *(null)* | /health |

**What gets flagged**

Request `R-002` took exactly 500 ms. With **Inclusive** off the comparison is `< 500`, so the row fails. `R-004` is NULL and passes without firing an anomaly. Coverage is 100%, so the failing row is reported as a Record Anomaly.

> **Example: Record Anomaly**
>
> response_ms has the value 500, which is not less than 500

**Flowchart**

```mermaid
graph TD
    A["No filter, evaluate all rows"] --> B["Read response_ms"]
    B --> C{"Is value NULL?"}
    C -->|Yes| D["Row passes"]
    C -->|No| E{"Is response_ms < 500?"}
    E -->|Yes| D
    E -->|No| F["Flag row.<br/>Record Anomaly per failing row."]
```

**Equivalent SQL**

```sql
-- Rows the Less Than check would flag.
SELECT r.*
FROM api_requests r
WHERE r.response_ms IS NOT NULL
  AND r.response_ms >= 500;
```

**Tab: Inclusive Discount Cap with Filter**

**The situation:** Promotional orders may carry a discount rate of at most 0.5. Exactly 0.5 is allowed, so **Inclusive** is on. Regular orders use a different policy and are out of scope.

**Check configuration**

| Field | Value |
| --- | --- |
| Rule | Less Than |
| Field | `discount_rate` |
| Filter | `order_type = 'promo'` |
| Custom Anomaly Description | Off |
| Value | `0.5` |
| Inclusive | On |
| Numeric | *(none)* |
| Coverage | 100% |
| Owner | *(check creator)* |
| Anomaly Assignee | *(Pricing Engineering)* |
| Description | Promotional discount rate must be at most 0.5. |
| Tags | `pricing`, `range` |
| Additional Metadata | `jira: DATA-8544` |
| Status | Active |

**Payload**

```json
{
    "description": "Promotional discount rate must be at most 0.5.",
    "rule": "lessThan",
    "fields": ["discount_rate"],
    "container_id": 512,
    "coverage": 1,
    "filter": "order_type = 'promo'",
    "properties": {"value": 0.5, "inclusive": true},
    "tags": ["pricing", "range"],
    "additional_metadata": {"jira": "DATA-8544"},
    "anomaly_message_field": null,
    "template_id": null,
    "status": "Active",
    "owner_id": 7,
    "default_anomaly_assignee_id": 29
}
```

**Sample Data** (filtered to `order_type = 'promo'`)

| order_id | order_type | discount_rate |
| --- | --- | --- |
| P-01 | promo | 0.20 |
| P-02 | promo | 0.75 |
| P-03 | promo | 0.50 |

**Why the filter matters**

The filter runs **before** the comparison, so regular orders are never tested against the promotional cap. Only promotional rows are evaluated.

**What gets flagged**

`P-02` exceeds the cap. `P-03` sits exactly on it and passes, because **Inclusive** is on. Coverage is 100%, so the failure is reported as a Record Anomaly, and the message names the filter that scoped the evaluation.

> **Example: Record Anomaly**
>
> discount_rate has the value 0.75, which is not less than 0.5 (applied to records where order_type = 'promo')

**Flowchart**

```mermaid
graph TD
    A["Apply filter: order_type = 'promo'"] --> B["Read discount_rate"]
    B --> C{"Is discount_rate <= 0.5?"}
    C -->|Yes| D["Row passes"]
    C -->|No| E["Flag row.<br/>Message names the filter:<br/>applied to records where order_type = 'promo'"]
```

**Equivalent SQL**

```sql
-- Rows the check would flag among promotional orders.
SELECT o.*
FROM orders o
WHERE o.order_type = 'promo'
  AND o.discount_rate IS NOT NULL
  AND o.discount_rate > 0.5;
```

**Tab: Computed Ratio with Tolerance**

**The situation:** A computed `utilization_ratio` must stay at or below 1, but the division accumulates floating-point error, so values land a hair above 1 without anything being wrong. An absolute tolerance of 0.0001 absorbs that. A pipeline fix is rolling out, so the check tolerates up to 0.5% failures.

**Check configuration**

| Field | Value |
| --- | --- |
| Rule | Less Than |
| Field | `utilization_ratio` |
| Filter | *(none)* |
| Custom Anomaly Description | Off |
| Value | `1` |
| Inclusive | On |
| Numeric | Absolute, 0.0001 |
| Coverage | 99.5% |
| Owner | *(check creator)* |
| Anomaly Assignee | *(Capacity Analytics)* |
| Description | Utilization ratio must be at most 1, within floating-point tolerance. |
| Tags | `capacity`, `plausibility` |
| Additional Metadata | `jira: DATA-8588` |
| Status | Active |

**Payload**

```json
{
    "description": "Utilization ratio must be at most 1, within floating-point tolerance.",
    "rule": "lessThan",
    "fields": ["utilization_ratio"],
    "container_id": 733,
    "coverage": 0.995,
    "filter": null,
    "properties": {"value": 1, "inclusive": true, "numeric_comparator": {"epsilon": 0.0001, "as_absolute": true}},
    "tags": ["capacity", "plausibility"],
    "additional_metadata": {"jira": "DATA-8588"},
    "anomaly_message_field": null,
    "template_id": null,
    "status": "Active",
    "owner_id": 7,
    "default_anomaly_assignee_id": 47
}
```

**Sample Data**

| resource_id | utilization_ratio | pool |
| --- | --- | --- |
| RS-01 | 0.83 | A |
| RS-02 | 1.00002 | A |
| RS-03 | 1.42 | B |
| RS-04 | 2.10 | B |

**What gets flagged**

`RS-02` is barely above 1 and falls inside the 0.0001 tolerance, so it passes. `RS-03` and `RS-04` exceed the cap by far more than the margin and fail. Only 50% of the rows pass, which is below the 99.5% coverage threshold, so the check reports a single Shape Anomaly for the dataset with a sample of the offending rows. Coverage below 100% does not produce Record Anomalies.

> **Example: Shape Anomaly**
>
> utilization_ratio values are not less than 1, affecting 2 of 4 asserted records

**Flowchart**

```mermaid
graph TD
    A["No filter, evaluate all rows"] --> B["Read utilization_ratio"]
    B --> C{"Is value NULL?"}
    C -->|Yes| D["Row passes"]
    C -->|No| E["Apply the 0.0001 tolerance"]
    E --> F{"Is the adjusted value <= 1?"}
    F -->|Yes| D
    F -->|No| G["Flag row.<br/>Passing rate falls below the 99.5%<br/>coverage, so one Shape Anomaly is reported."]
```

**Equivalent SQL**

```sql
-- Rows the check would flag, allowing a 0.0001 tolerance.
SELECT r.*
FROM resource_usage r
WHERE r.utilization_ratio IS NOT NULL
  AND (r.utilization_ratio - 0.0001) > 1;
```

## See Also

- **How It Works**

  The complete reference: definition, field scope, the threshold, inclusivity, the numeric comparator, NULL handling, filter behavior, and coverage.

  [How It Works](https://userguide.qualytics.io/data-quality-checks/less-than/deep-dive/how-it-works/)
- **Anomaly Reporting**

  The anomaly messages the check produces, what the numbers mean, Source Records highlighting, and Custom Anomaly Description.

  [Anomaly Reporting](https://userguide.qualytics.io/data-quality-checks/less-than/deep-dive/anomaly-reporting/)
- **Best Practices**

  Guidelines for setting the threshold, using inclusivity and tolerance, and keeping the signal clean.

  [Best Practices](https://userguide.qualytics.io/data-quality-checks/less-than/deep-dive/best-practices/)
- **Permissions**

  The team permission each action needs: view, create, edit, archive, restore, and delete.

  [Permissions](https://userguide.qualytics.io/data-quality-checks/less-than/deep-dive/permissions/)

*Last updated: September 22, 2026.*
