• English

# Technical Details of the Expression Editor

Article Summary

There are two places you can use expressions: in the App Editor and in the Analytics Editor. Both of these options have different methods and scenarios for using expressions, so make sure to familiarize yourself with their respective formats.

## Types

Every field, value, and sub-expression has a data type that allows the Tulip system to check whether your Expression is valid.  This prevents expression from operations like adding 3 to a day of the week.  As long as your expression makes logical sense you should not run into any type errors; however, if you do, the editor will display an error with the rule you have violated.  The Expression Editor uses the following types:

• Text: A sequence of characters, like “foo” or “abc123”.
• Integer: An integer (a number without a fractional component), like -3, 0, or 5.
• Number: Any real number, like -3.2, 0, 3, or 4.2345.
• Interval: An amount of time, measured in seconds.
• Boolean: true or false.
• Day of Week: A day of the week, like Monday or Saturday.
• Date: A date, like Wednesday, November 29th, 2017.
• Datetime: A time and date, like Wednesday, November 29th, 2017 at 1:05 PM EST.
• Week: A week, like the week starting on Monday, November 27th, 2017.
• Month: A month, like November 2017.
• User: Any user in the Tulip system, as described here.
• Station: Any station on the shop floor, as described here.
• App: Any Tulip app.
• App Version: A version of an app, as described here.

## Operators

In Tulip, you can use basic arithmic operators to perform an action with your data.
Operators with one operand (a value) perform an action with a single operand.
Ex: -X, negates the value of the operand X

Binary operators perform actions with two operands.
Ex: X+Y, adds the values of the two operands X and Y

In a complex expression, (two or more operands) the order of evaluation depends on a set of rules as follows:

1. parantheses
2. exponents
3. multiplication and division

Ex: X * A + Y * B, multiplies the values of X and A as well as the values of Y and B. Those respective values are then added together.

Expressions are evaluated left to right. Complex expressions which use multiple operators and functions of the same type are evaluated in order of the operators used.

### !

Logical NOT. Returns true if and only if its argument is false.
Ex: @variable.work_order_number != 123456

### =

Checks if the value of two operands are equal or not, if yes, then the condition becomes true.
Ex: (A = B)

### >

Checks if the value of the left operand is greater than the value of the right operand, if yes, then the condition becomes true.
Ex: (A > B) is not true.

### <

Checks if the value of the left operand is less than the value of the right operand, if yes, then the condition becomes true.
Ex: (A < B) is true.

### >=

Checks if the value of the left operand is greater than or equal to the value of the right operand, if yes, then the condition becomes true.
Ex: (A >= B) is not true.

### <=

Checks if the value of the left operand is less than or equal to the value of the right operand, if yes, then the condition becomes true.
Ex: (A <= B) is true.

### &

Logical AND. If both the operands are non-zero, then the condition becomes true.
Ex: (A & B) is true.

### |

If any of the two operands are non-zero, then the condition becomes true.
Ex: (A | B) is true.

### +

Ex: A + B will give 30

### -

Subtracts the second operand from the first
Ex: A - B will give -10

### *

Multiply both operands
Ex: A * B will give 200

### /

Divide the numerator by the denominator
Ex: B / A will give 2

### %

Outputs the remainder of an integer division
Ex: B % A will give 0

## Functions

The list of available functions differ between the App Editor and the Analytics Editor. Review the respective lists so you know exactly which expressions can be used and when.

Did you find what you were looking for?

You can also head to community.tulip.co to post your question or see if others have faced a similar question!