# Rule action: Item group rules

Used for: Calculations on group level rather than individual item level.

Used in: "THEN"-statements and "ELSE"-statements.

### General improvement

The four new rules are all a subset of rules under the parent rule called "Calculate item group".

You can use these rules without having to group the items beforehand. You can use these rules on groups of items that share values in a certain field. The most obvious one is item\_group\_id, but you can also create your own groups of items.

{% stepper %}
{% step %}

### Count items

The "count items" rule counts the number of products/items within a certain group.

As shown in the app, first choose a mutual id or some field that identifies the group (for example, `item_group_id`). Then select the rule and choose a field where the result of the calculation will be stored.

The result of this rule will always be a number (the number of products in the product\_group).

Example use cases:

* Group vacancies by `branch + city` and count how many vacancies a branch has in a specific area.
* Group real estate by `type of house + area` and count how many houses of that type exist in an area.
* For travel, calculate the number of accommodations available per city or tickets on a route.

<figure><img src="/files/c1a4236375e6ad7f45a154d00eecf7cdf0d3450a" alt=""><figcaption></figcaption></figure>

{% endstep %}

{% step %}

### Calculate sum

The "calculate sum" rule computes the sum of a specific numeric field for all items within a group.

Workflow:

* Choose the group identifier (e.g., `item_group_id`).
* Select the "calculate sum" rule.
* Select the numeric field to sum (for example, `Stock`).

The result is the total amount across the group. For example, if you have 10 items in the group and each has `stock = 3`, the result will be 30.

<figure><img src="/files/e81f41925c4eb993a3ab6302a00c21af02fc9965" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

### Find highest / lowest value

There are two complementary rules: "find highest value" and "find lowest value". Each finds the extreme value of a specified field across all items in the group and stores that value in a chosen field.

Important: Click the Sort numbers button in the bottom right corner of the THEN-STATEMENT to find the highest or lowest value of the intended field.

<figure><img src="/files/9111725beda1a058ad636d23adbb28e35afb54bf" alt=""><figcaption></figcaption></figure>

Use cases:

* Flights: find the lowest price among various dates/offers and advertise "available from \[lowest price]".
* Product advertising: find the lowest price within a brand or category and use it in promotional text like "starting from \[lowest\_price\_of\_brand]".

Note: Unlike a deduplicate rule that would keep only the highest or lowest item, these rules keep all items and simply store the highest/lowest value for the group.

The "find highest value" rule works the opposite way (finds the maximum value).
{% endstep %}
{% endstepper %}


---

# 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://helpcenter.channable.com/manage-improve-product-data/rules-bulk-edit-and-enrich/how-to-use-actions-then-in-rules/rule-action-item-group-rules.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.
