# All Quire Operators and Functions

## Numeric operators

Operators Description Example
+ Add the numeric values `timeSpent + 100`
- Subtract the numeric values `Cost - 100`
* Multiply the numeric values `Cost * 100`
/ Divide the numeric values `Cost / 100`
% Calculate the remainder `Cost % 3`
^ Calculate the power of the value `Cost ^ 3`

Note: In the above examples, you have to create a custom field named `Cost` first.

## Text operators

Operators Description Example
+ Concatenate two text strings `‘This is’ + ‘a task’`

## Comparison operators

Operators Description Example
< Less than `3 < 1` -> False
> Greater than `4 > 3` -> True
<= Less than or equal to `4 <= 2` -> False
>= Greater than or equal to `5 >= 1` -> True
= Equal to `2 = 2` -> True
!= Is not equal to `3 != 2` -> True

## Logical operators

#### `not`

• Description: Checks if the argument returns false and returns a true/false value as result.
• Example:
``````Not (Cost > 50)
``````
• Expected result: If the value in the `Cost` field is larger than 50, then it will return a false value. If not, it will return as a true value.

Note: For the above example, you have to create a custom field named `Cost` first.

#### `in`

• Description: Checks if all returned values of the first argument are included in the returned values of the second argument and returns a true/false value.
• Example:
``````assignees in subtasks.assignees
``````
• Expected result: If all the assignees of the task is included in the subtasks’ assignees, then it will return as a true value.

#### `&`

• Description: Checks if the values of input arguments in front of and after the ampersand (&) have something in common and returns the common value.
• Example:
``````assignees & subtasks.assignees
``````
• Expected result: If any assignees of the task are also assigned to the subtasks, the assignee(s) will show as the returned result.

#### `and`

• Description: Tests the arguments and returns true if all are met. Returns false otherwise.
• Example:
``````(Cost > 50) and (due > <today>)
``````
• Expected result: If the value of the `Cost` field is larger than 50 and the due date of the task is larger than today (if the due date is in the future), then it will return true.

Note: For the above example, you have to create a custom field named `Cost` first.

#### `or`

• Description: Checks if any of the arguments evaluates to be true, then returns a true value.
• Example:
``````Cost or Budget
``````
• Expected result: If there is a value either in the `Cost` field or in the `Budget` field, then it will return true.

Note: For the above example, you have to create two custom fields named `Cost` and `Budget` first.

## List operators

#### `[field, field]`

• Description: Lists out all the values of the arguments.
• Example:
``````[me, #23.assignees, subtasks.assignees]
``````
• Expected result: It will list out me, the assignees that are assigned to task with the ID#23 and all the assignees of the subtasks.

Learn more about Quire’s array formulas that allows you to list out or do calculations to a collection of data.

#### `field[index]`

• Description: Retrieves an item for the list.
• Example:
``````subtasks
``````
• Expected result: It will return the 4th subtask.

Note: The first item in the list starts with 0.

#### `order by`

• Description: Lists out the tasks that fit the input argument and returns a new list with the specified order.
• Example:
``````subtasks order by any.Cost
``````
• Expected result: It will list out the subtasks and order them based on their values of their `Cost` fields.

Note: For the above example, you have to create a custom field named `Cost` first.

Tip: You can also specify the sorting order by adding `asc` or `desc` at the end of the expression. For example, you can type something like: `subtasks order by any.Cost asc`.

#### `map`

• Description: Lists out the tasks that fit the input arguments and returns a new list with the calculation.
• Example:
``````subtasks map any.Cost * 2
``````
• Expected result: It will list the values in the `Cost` field of the subtasks and times the values by 2.

Note: For the above example, you have to create a custom field named `Cost` first.

Tip: You can use the `any` identifier with the `map` operator to call out the field you want to calculate.

## Conditional operators

#### `??`

• Description: Checks if the task fits the expression in front of the `??` and returns a true/false value. If the task doesn’t match the expression, then returns the value of the expression after the `??`.
• Example:
``````(Cost > 10) ?? 'Reconsider'
``````
• Expected result: If the value in the `Cost` field is larger than 10, then it will return as true. If smaller than 10, then it will show as false. When there’s no value entered in the `Cost`, then it will show “Reconsider”.

Note: For the above example, you have to create a custom field named `Cost` first.

#### `?:`

• Description: Checks if the task fits the expression in front of the `?` and return the expression after `?`. If the task doesn’t match the expression in front of the `?`, then will return the expression after the `:`.
• Example:
``````(Cost > 10) ? 'Too expensive': 'Reconsider'
``````
• Expected result: If the value in the `Cost` field is larger than 10, then it will show “Too expensive”. If it is smaller than 10 or if there’s no value entered at all, then it will show “Reconsider”.

Note: For the above example, you have to create a custom field named `Cost` first.

## Filter operators

#### `where`

• Description: Filters and lists out the tasks that fit the stated conditions.
• Example:
``````subtasks where any.Cost > 10
``````
• Expected result: Subtasks that have a cost value larger than 10 will be listed.

Note: For the above example, you have to create a custom field named `Cost` first.

Tip: You can use the `any` identifier with the `where` operator to specify the field you want to filter.

#### `limit`

• Description: Lists out the tasks that fit the input argument and returns a new list with the specified limited number of tasks.
• Example:
``````subtasks order by desc any.timeSpent - any.estimated limit 3
``````
• Expected result: It will list out the top 3 subtasks that have a larger time spent value than the estimated time value.

## Operator precedence

In some cases, the order of the calculation can affect the return value of the formula, that’s why it is important to understand the order of the operations in Quire. If you combine different operators in one formula, Quire will perform the operation in the order shown in the below table. If the formula has operators that have the same order, then Quire will calculate from left to right.

Operator Description
`( )`
`.`
`[ ]`
`( )`
Parentheses
Dot operator
List (Array)
Function call
`+`
`-`
`not`
Unary operators
`^` Exponentiation
`*`
`/`
`%`
Multiplication and division
`+` `-` Addition and subtraction
`<`
`>`
`<=`
`>=`
`in`
`&`
Comparison operators
`=`
`!=`
Equation operators
`not` Logical `not` operator
`and` Logical `and` operator
`or` Logical `or` operator
`??` Conditional operator
`where` Filter operator
`?:` Conditional operator

## All functions

Function Description Example Expected results
SUM() Returns the total of the values. `SUM(subtasks.estimated)` It will add up all the values in the Estimate fields of the task’s subtasks.
MAX() Returns the largest value in a set of values. `MAX(subtasks.estimated)` It will show the largest value that can be found in the Estimate fields from the task’s subtasks.
MIN() Returns the smallest value in a set of values. `MIN(subtasks.estimated)` It will show the smallest value that can be found in the Estimate fields from the task’s subtasks.
AVG() Returns the average value of the numbers. `AVG(subtasks.estimated)` It will calculate the average of the Estimate fields from the task’s subtasks.
COUNT() Returns the number of items. `COUNT(subtasks)` It will show the total number of subtasks.
SORT() Returns the sorted order of the arguments. `SORT(subtasks.estimated)` It will show all the values from the Estimate fields from the task’s subtasks in a sorted order.
DISTINCT() Removes duplicate values and returns only with distinct values. `DISTINCT(subtasks.estimated)` It will show all the distinct values from the Estimate fields from the task’s subtasks and remove the duplicate values.
ISEMPTY() Checks if the input arguments are empty or not and returns a true/false value. `ISEMPTY(estimated)` If the Estimate field of the task is empty, then it will show a checked checkbox.
ISNOTEMPTY() Checks if the input arguments are empty or not and returns a true/false value. `ISNOTEMPTY(estimated)` If the Estimate field of the task is not empty, then it will show a checked checkbox.

Last updated on