-
Notifications
You must be signed in to change notification settings - Fork 0
Expression Language
Tarun Abichandani edited this page Jan 18, 2024
·
2 revisions
Resseract Lite supports expressions at various places, for example, slice expression, adding custom columns, etc.
Resseract Lite supports the following data type
- Columns
- Categorical Columns : Categorical Columns are columns which contain string values
- Numerical Columns : Numerical Columns are columns which contain numbers
- Date Columns : Date Columns are columns which contain date or date time values
- Boolean Columns : Boolean Columns are columns which boolean values (true, false)
- Constants
- String : String Constants are constants which are of String type (e.g.
"Hello"
) - Boolean : Boolean Constants are constants which are of Boolean type (e.g.
true
,false
) - Number : Number Constants are constants which are of number type (e.g.
1
,2
)
- String : String Constants are constants which are of String type (e.g.
Resseract Lite support following operators
- Arithmetic operators
Sr.No | Operator | Description | Example |
---|---|---|---|
1 | +(Addition) | returns the sum of the operands | a+b is 15 |
2 | -(Subtraction) | returns the difference of the values | a-b is 5 |
3 | * (Multiplication) | returns the product of the values | a*b is 50 |
4 | / (Division) | performs division operation and returns the quotient | a / b is 2 |
5 | % (Modulus) | performs division operation and returns the remainder | a % b is 0 |
- Relational operators Assume the value of variable A is 10 and B is 20.
Sr.No | Operator | Description | Example |
---|---|---|---|
1 | > | Greater than | (A > B) is False |
2 | < | Lesser than | (A < B) is True |
3 | >= | Greater than or equal to | (A >= B) is False |
4 | <= | Lesser than or equal to | (A <= B) is True |
5 | == | Equality | (A == B) is fals |
6 | != | Not equal | (A != B) is True |
- Logical Operators Assume the value of variable A is 10 and B is 20.
Sr.No | Operator | Description | Example |
---|---|---|---|
1 | && (And) | The operator returns true only if all the expressions specified return true | (A > 10 && B > 10) is False |
2 | || (OR) | The operator returns true if at least one of the expressions specified return true | (A > 10 || B >10) is True |
Resseract Lite Supports the following functions
Sr.No | Function | Description | Example |
---|---|---|---|
1 | ceil([NUMERICAL COLUMN]) |
Returns the closest integer value which is greater than a decimal value | ceil([1.2, 2.3]) = [2,3] |
2 | cumulativesum([NUMERICAL COLUMN]) |
Returns cumulative sum of the column in another column | cumulativesum([1,2,3]) = [1,3,6] |
3 | formatdate([NUMERICAL COLUMN], format) |
Accepts Date Column and returns Categorical Column in formatted format | formatdate([1/1/24, 31/2/23], "MM/yy") = [01/24, 02/23] |
4 | groupedsum([NUMERICAL COLUMN], groupColumn) |
Groups data using the groupColumn and returns sum of each group in another column |
groupedsum([1,2,3], "C1") = [4,2,4] , where C1=["A", "B", "A"]
|
5 | if([condition], [true statement], [false statement]) |
Evaluates the if condition and if true, executes true statement else returns false statement |
if([C1] > [C2], "C1", "C2) = [C1, C2, C1] where C1=[1,2,3] and C2=[0,1,2]
|
6 | max([NUMERICAL COLUMN]) |
Evaluates the column and returns a column with max value | max([1,2,3]) = [3,3,3] |
7 | now() |
Returns a new column with current date | now() = [1/1/23, /31/2/24] |
8 | parsedate([CATEGORICAL COLUMN], format) |
Parses the date in categorical column and returns a Date Column | parsedate([01/24, 02/23], "MM/yy") = [1/1/24, 31/2/23] |
9 | sum([NUMERICAL COLUMN]) |
Evaluates the column and returns a column with sum of all values in the column | sum([1,2,3]) = [6,6,6] |
10 | tostring([COLUMN]) |
Converts any column to Categorical Column | tostring([1,2,3]) = ["1", "2", "3"] |
If your data has 2 numerical columns, Cost Price
, Sell Price
- A expression like
[Cost Price] - [Sell Price]
will give a numerical column (Profit
) - A expression like
[Cost Price] > [Sell Price]
will give a boolean column (Is Profit
) - A expression like
[Cost Price] + 10
will give a numerical column with 10 added to all values in the column - A expression like
if([Cost Price] > [Sell Price], "Profit", "Loss")
will give a Categorical column with "Profit" and "Loss" values