# Conditions

## Overview

Under Conditions you can define a list of constraints and criteria to filter records in the result of the query.

![Definition of Conditions in a query](/files/-MBWopKQfjb2PDqX8csb)

You can either add an individual condition or a group (of conditions) to the list. Complex scenarios using multiple conditions and multiple groups are possible.

## Add a Condition

To retrieve only data that adheres to certain criteria you add one or more conditions to your query. Click on **Add condition** at the top of the list to get started.

![Adding conditions to filter records of a query](/files/-MBWtrdbcJzGY1-_2WDE)

The newly created row the selection of a field from the available classes - Source and Query Context -, and how the field values should be evaluated against the comparison operator and an optional value.

{% hint style="info" %}
The default type of a value is a Constant. More about value types in the next paragraph.

When you choose a logical comparison operator, e.g. `Is empty` then it is not necessary (and possible) to specify a value.
{% endhint %}

## Edit a Condition

In the **Actions** columns you have the ability to **Edit** <img src="/files/-MBCo7T7BtG64Zwffv31" alt="" data-size="line"> , **Delete** <img src="/files/-MBERLm_rQfmOyoGQJFV" alt="" data-size="line"> , and **Position** <img src="/files/-MBEACmVckVy-uZ1eKqH" alt="" data-size="line"> the selected row.

Click on the **Edit** icon <img src="/files/-MBCo7T7BtG64Zwffv31" alt="" data-size="line"> to open a detailed view of the properties of the condition.

![Review and edit properties of a condition](/files/-MBWwHyYuowkJneXKaG_)

The **Condition Properties** view lets you choose a Field and how it compares to a certain constraint. Analogue to the Field selection in the list of conditions you can choose any entity from the available classes provided by Source and Query Context.

Next, you specify the comparison operator by choosing an option from the drop-down list. Ticking the **Not** checkbox negates the operation.

### Comparison Operators

To compare your Field against a certain information you have to specify the comparison operator.

![Choose a comparison operator to specify the condition to filter values](/files/-MBXKFz0pemtiCLpUyBl)

By default it is the *is equal to* operator `=`. The list of comparison operators is given below.

* Is equal to `=`&#x20;
* Is not equal to `<>`&#x20;
* Is less than `<`&#x20;
* Is less than or equal to `<=`&#x20;
* Is greater than `>`&#x20;
* Is greater than or equal to `>=`&#x20;
* `Begins with`&#x20;
* `Contains`&#x20;
* `Ends with`&#x20;
* `In`&#x20;
* `Is Null`&#x20;
* `Is Not Null`
* `Is Empty`&#x20;
* `Is Not Empty`&#x20;
* `Is Null or Empty`&#x20;

The comparison operators describing a state of a field value, e.g. `Is Empty`, do not require a value to compare against.

![Using a state-based comparison operator, here: \`Not Null\`](/files/-MBWuzHpZYXKP6McS9xO)

### Types of Comparison

Then you select the type of value against which the field records should be compared to. The following types are available.

* Constant
* Expression

Each type has its individual detail to complete the condition.

#### Constant

A constant lets you define a fixed value against which the field values are compared to. A common scenario would be to check for non-negative numbers (e.g. greater than or equal zero) or whether a certain string is present (e.g. contains value).

![Comparing records to multiple, constant values in a query](/files/-MBWyEwrZujlJRGpeBXQ)

Enter multiple values as comma-separated list when using the `In` comparison operator.

#### Expression

An expression offers more flexibility compared to a constant and its value is evaluated during the execution of the query. Specify an expression by writing the reference in curly brackets, e.g. {CurrentUser.Id}.&#x20;

![Using an expression provides flexibility as the value is evaluated at execution of a query](/files/-MBWy_uGvQLd03X-nRrg)

A sample condition to display records which have been created by the current user only, you would select a field like `Source.Created By` and check whether its values are equal (`=`) to the current user, represented by the expression `{CurrentUser.Id}` .

Expressions are a feature of the [Scripting](/building-an-application/execution/scripting.md) capabilities of the platform. You can find out more about [Expressions here](/building-an-application/views/document-templates/expressions-in-template.md).

## Add a Group

Combining multiple conditions into a logical unit is called a group. You can define your list of conditions with any number of groups together with individual conditions. In logical terms, a group acts as a set of parentheses around your conditions.

![Add a group of conditions to a query](/files/-MBX4fo9Zv6C6MFX-F8u)

The use of a group gives priority to a certain set of conditions in regards to the sequence of they are evaluated against the Source of your query. A group allows you define a more complex list of conditions, e.g. to filter records by certain constraint A but not following criteria B or C.

## Logical Operators

When working with multiple conditions to filter your data you have to provide information of how those criteria are to be combined. Logical operators are used to link those conditions.

![Combine multiple conditions with logical operators](/files/-MBX6_rnHTTjdjS0hOJL)

Following operators are available to create more versatile conditions.

* `And` - both criteria must be met to accept any value as result
* `Or` - any criteria must be met to accept a value in the result&#x20;
* `None` - is a construct which stands for `And Not` when combining multiple criteria&#x20;

## Delete a Condition

To remove a single condition or a group from the list of conditions click on the **Delete** icon <img src="/files/-MBERLm_rQfmOyoGQJFV" alt="" data-size="line"> in the column Actions. Repeat to remove more than one row from the list.

{% hint style="info" %}
Deleting a group removes all conditions inside that group.
{% endhint %}


---

# 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.tivity.one/building-an-application/data/query-data/query-designer-conditions.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.
