# 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](https://2165942204-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MMKXTFIN5ZlLOjBlfC4%2Fuploads%2F4brHHuTGm24JZzYF2sPT%2Fscreely-1685032863646.png?alt=media\&token=444d1f0f-8f11-458b-b636-715305dfde8a)

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](https://docs.akenza.io/akenza.io/deprecated/custom-logic-blocks) can be defined in order to execute more control of the rule logic evaluation.
{% endhint %}

![Rule logic](https://2165942204-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MMKXTFIN5ZlLOjBlfC4%2Fuploads%2FlKCfj9Bta12VJjuN1L9z%2Fscreely-1685032940954.png?alt=media\&token=4d88b708-6c1e-44cb-b452-2274a2b1e277)
