# Comparison

The **Comparison Logic Block** consists of two sections:&#x20;

* Data sources
* Conditions

The data source section is used to specify which **topic** of a data sample triggers the logic block and which property of that data sample is further used in the condition section. At least one data source is required, more can be added if the logic requires.&#x20;

{% hint style="info" %}
One device can be assigned to **multiple data sources**, depending on how many keys of the sample should be evaluated in the conditions.&#x20;
{% endhint %}

If a device type schema is present, the **data source** selection allows choosing data points from the device type schema. If no schema is present, the **topic** and **data key** have to be entered on the comparison logic block.

{% hint style="warning" %}
The **topic** and the **data key** of a data sample can be also viewed within *Message Logs* on the *Device Detail Page* of a device. To match all topics, `*`can be used.
{% endhint %}

![Topic and data key in message logs](/files/3nXQmrPbz3itKueTwfIj)

In the condition section, the **data source** alongside a comparison operator is used to compare the value of a data sample, to a **constant number** or the **latest sample** of another data source.\
Nested conditions can be configured using the *plus* button which adds another comparison block in the condition.&#x20;

The modifiers for `is`, and `is not` can be changed by clicking on the blue text.\
When adding additional conditions, they are not linked to one another. Each condition (if it evaluates to true) will trigger the assigned output.&#x20;

This setup allows for quite complex logic to be applied to newly received samples without having to write any code.

{% hint style="info" %}
If the comparison logic is not sufficient, a [Custom Logic Block](/akenza.io/deprecated/custom-logic-blocks.md) can be defined in order to execute more control of the rule logic evaluation.
{% endhint %}

![Rule logic](/files/Hgz0uFEynOWUO8soICFG)


---

# 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.akenza.io/akenza.io/get-started/rule-engine/logic-blocks/rule-logic.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.
