# Min/max rule

### Why do we need min/max rules in reports?

{% hint style="success" %}
Min/max rules can prevent entries such as percentages above 100, or budgets that fall outside the specified business range. Catching out-of-range values reduces corrections and rework down the line. Outliers caused by data entry errors can skew trends and KPIs - min/max rules help avoid false alarms.
{% endhint %}

In this section, we'll look at how to configure min/max rules. Inforiver Writeback Matrix supports 3 types of rules:

* **Static values**: Enter the minimum and maximum values that can be entered.
* **Measure-based:** The range is calculated based on the minimum and maximum values in the selected measure. &#x20;
* **Variable-driven:** Min/max values can be controlled by variables.

<figure><img src="/files/F9VFQdrUz1KZEErUACuM" alt=""><figcaption><p>Types of min/max rules</p></figcaption></figure>

### Step-by-step guide to setting up min/max rules

#### 1. Min/max rules with static values

In this example, the interest and rebate rates are percentages. We'll look at how to enforce a numeric range rule for these fields.

**STEP 1:** Choose the **Selected Measures** from the **Apply to** dropdown and select the Interest Rate and Rebate Rate options from the **Choose Measures** dropdown.

**STEP 2:** Select the **Static** option from the **Minimum Value** and **Maximum Value** section.

<figure><img src="/files/yVvBbpQz16VrE5WH94Kj" alt=""><figcaption><p>Apply the rule to selected measures and choose the static option</p></figcaption></figure>

**STEP 3:** Enter the values that will define the upper and lower bounds of the acceptable range. We have set the lower limit to 1.25 and the upper limit to 18.95.

<figure><img src="/files/hx0EK3bTheRfmMAkeYpt" alt=""><figcaption><p>Assign the upper and lower limits</p></figcaption></figure>

**STEP 4:** Select the **Custom** option and select the target rows and columns the rules should be applied to. We've selected only the child rows and excluded the total and grand total rows and columns.

<div><figure><img src="/files/OX2kpTRWqVQYkxP92XqN" alt=""><figcaption><p>Row selection to exclude totals</p></figcaption></figure> <figure><img src="/files/ZCCfr8P4ehMvmrBBV8iP" alt=""><figcaption><p>Column selection to exclude totals</p></figcaption></figure></div>

<figure><img src="/files/lzlQrKARuCnWDenQk8iF" alt=""><figcaption><p>Apply rules to specific rows and columns</p></figcaption></figure>

Notice how values outside the defined range are not accepted.&#x20;

<figure><img src="/files/rrnth683qJYeOhiYNHxF" alt=""><figcaption><p>Inforiver throws an error when values outside the defined range are entered</p></figcaption></figure>

#### 2. Min/max rules with variables

Another option is to control the minimum and maximum values with variables.&#x20;

**STEP 1:** Define numeric variables to control the minimum and maximum limits.

<figure><img src="/files/j0Y2jwPGWpM1E4lNyuX9" alt=""><figcaption><p>Define variables to control minimum and maximum values</p></figcaption></figure>

**STEP 2:** Select **Variable** and choose the variables defined in STEP 1 in the **Minimum Value/Maximum Value** section.

<figure><img src="/files/ncYJgb6YlODsKEhxMYet" alt=""><figcaption><p>Select the pre-defined variables that will be used to control the value range</p></figcaption></figure>

**STEP 3:** In the **Target Rows** section, let's select Custom and choose the child categories. The range rules will apply only to the selected child rows. This step is optional and depends on specific requirements.

<figure><img src="/files/mp1YfvTEIj11O4489GBr" alt=""><figcaption><p>Select the rows to apply rules to</p></figcaption></figure>

With variables, the upper and lower limits can be controlled dynamically, as shown in the animation.

<figure><img src="/files/yizr9JyhZaEKdsHDkmGb" alt=""><figcaption><p>Use variables to control min and max values</p></figcaption></figure>

### Configuration options for min/max rules

Basic configurations are covered in the [Data validation rules](/working-with-inforiver/4.-adding-business-logic-and-formulae/data-validation-rules.md) section. The options specific to mix/max rules are covered in this section.

#### 2.1. Set exclusive

Use **Set Exclusive** to exclude boundary values, ensuring the minimum is greater than and the maximum is less than the specified limits - for example, when the minimum value must be greater than (but not equal to) the lower limit, and the maximum value must be less than (but not equal to) the upper limit.

In the animation, notice how the visual does not accept 1.25 although it is the lower bound. This is because the Set Exclusive option has been enabled.

<figure><img src="/files/VTWpcX9oD1jn7keoQeJu" alt=""><figcaption><p>Error when entering the lower bound value when set exclusive is enabled</p></figcaption></figure>

#### 2.2. Mimimum/Maximum value

In the first section, we used static values to set the upper and lower limits. You can also use measures from your report as the min/max values.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.inforiver.com/working-with-inforiver/4.-adding-business-logic-and-formulae/data-validation-rules/min-max-rule.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
