Skip to content

RangeCompare Conditional

This conditional compares a value against an upper and lower range limit. If the value is within the range, it resolves to true.

Schema

key type required description
type string required A string defining the type of conditional as rangeCompare.
operator string required A string that defines the comparison operation to perform. Valid values are inRange and notInRange.
string number required The string that will be used when evaluating the conditional.
valueQuery string optional A JSONata query whose result will be used as the right operand in the comparison. The query must resolve to a single string, integer or float value. If a string, it may contain currency and comma separators (i.e. $12,345.56). If valueQuery is not provided, the data associated with the object containing the conditional is used for comparison. For example, a textOptions defined in a style on a table's column may include a conditional. If the valueQuery property is not defined, the conditional will be evaluated for each row in the table. See value compare for an example of how to apply conditionals to tables.

Example

The following examples shows how a component may be rendered only when the specified condition evaluates to true. The rangeCompare conditional will evaluate the sum of all sales.total data and include the component only when the value is between 0 and 100.

{
    "type": "Text",
    "text": "Total sales for the quarter were @($sum(sales.total))",
    "condition": {
        "type": "rangeCompare",
        "operator": "inRange",
        "valueRange": {
            "lowValue": 0,
            "highValue": 100
        },
        "valueQuery": "$sum(sales.total)"
    }
}