Browse Source

Update formulas.md

- Adding formula column
- Corrections to formula table
pull/865/head
Raju Udava 3 years ago committed by GitHub
parent
commit
80866bbfbe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 82
      packages/noco-docs/content/en/setup-and-usages/formulas.md

82
packages/noco-docs/content/en/setup-and-usages/formulas.md

@ -6,44 +6,58 @@ category: 'Usage'
menuTitle: 'Formulas' menuTitle: 'Formulas'
--- ---
## Adding Formula column
![Formula](https://user-images.githubusercontent.com/86527202/144246227-42c44df6-7e3e-4b2c-9bb9-a3c213bcad20.png)
#### 1. Click on '+' (Add column)
#### 2. Populate Column Name
#### 3. Select Column Type as 'Formula'
#### 4. Insert required formula
- Can use column names in equation
- Can use explicit numberical values/ strings as needed
- Table below lists supported formula & associated syntax
- Nested formula (formula equation referring to another formula column) are not supported
#### 5. Click on 'Save'
## Available Formula Features ## Available Formula Features
### Functions ### Functions
| Name | Syntax | Sample | Description | | Name | Syntax | Sample | Output | Minimum arguments |
|---|---|---|---| |---|---|---|---|---|
| AVG | `AVG(value1, [value2,...])` | `AVG(Column1, Column1)` | Calculates the average of provided values and it requires minimum 1 argument | | AVG | `AVG(value1, [value2,...])` | `AVG(Column1, Column1)` | Average of input parameters | 1 |
| ADD | `ADD(value1, [value2,...])` | `ADD(Column1, Column1)` | Calculates the sum of provided values and requires a minimum of 1 argument | | ADD | `ADD(value1, [value2,...])` | `ADD(Column1, Column1)` | Sum of input parameters | 1 |
| CONCAT | `CONCAT(value1, [value2,...])` | `CONCAT(FirstName, ' ', LastName)` | Outputs concatenated string of provided arguments | | CONCAT | `CONCAT(value1, [value2,...])` | `CONCAT(FirstName, ' ', LastName)` | Concatenated string of input parameters |
| TRIM | `TRIM(value1)` | `TRIM(Title)` | Removes trailing and leading whitespaces | | TRIM | `TRIM(value1)` | `TRIM(Title)` | Removes trailing and leading whitespaces from input parameter |
| UPPER | `UPPER(value1)` | `UPPER(Title)` | Converts provided string arguments to upper case | | UPPER | `UPPER(value1)` | `UPPER(Title)` | Upper case converted string of input parameter |
| LOWER | `LOWER(value1)` | `LOWER(Title)` | Converts provided string arguments to lower case | | LOWER | `LOWER(value1)` | `LOWER(Title)` | Lower case converted string of input parameter |
| LEN | `LEN(value)` | `LEN(Title)` | Outputs provided arguments character length | | LEN | `LEN(value)` | `LEN(Title)` | Input parameter charachter length |
| MIN | `MIN(value1, [value2,...])` | `MIN(Column1, Column2, Column3)` | Outputs lowest value among provided arguments | | MIN | `MIN(value1, [value2,...])` | `MIN(Column1, Column2, Column3)` | Minimum value amongst input parameters |
| MAX | `MAX(value1, [value2,...])` | `MAX(Column1, Column2, Column3)` | Outputs greatest value among provided arguments | | MAX | `MAX(value1, [value2,...])` | `MAX(Column1, Column2, Column3)` | Maximum value amongst input parameters |
| CEILING | `CEILING(value1)` | `CEILING(Column)` | Rounds a number up to the next largest integer value | | CEILING | `CEILING(value1)` | `CEILING(Column)` | Rounded next largest integer value of input parameter |
| FLOOR | `FLOOR(value1)`| `FLOOR(Column)` | Outputs the largest integer which is less than or equal to the provided | | FLOOR | `FLOOR(value1)`| `FLOOR(Column)` | Rounded largest integer less than or equal to input parameter |
| ROUND | `ROUND(value1)`| `ROUND(Column)` | Outputs the nearest integer to the provided value | | ROUND | `ROUND(value1)`| `ROUND(Column)` | Nearest integer to the input parameter |
| MOD |`MOD(value1, value2)` | `MOD(Column, 2)` | Outputs the remainder after integer division, it requires 2 arguments | | MOD |`MOD(value1, value2)` | `MOD(Column, 2)` | Remainder after integer division of input parameters | 2 |
| REPEAT | `REPEAT(value1, count)`| `REPEAT(Column, 2)` | Generate a specified number of copies of the string concatenated together | | REPEAT | `REPEAT(value1, count)`| `REPEAT(Column, 2)` | Specified copies of the input parameter string concatenated together |
| LOG | `LOG(value1, [base])`| `LOG(Column)` | Outputs logarithm of a value| | LOG | `LOG(value1, [base])`| `LOG(Column)` | Logarithm of input parameter to the base specified |
| EXP | `EXP(value1)` | `EXP(Column)` | Outputs the exponential value of a number (`e^x`) | | EXP | `EXP(value1)` | `EXP(Column)` | Exponential value of input parameter (`e^x`) |
| POWER | `POWER(base, exponent)` | `POWER(Column, 3)` | Outputs the `base` to the `exponent` power, as in `base^exponent`| | POWER | `POWER(base, exponent)` | `POWER(Column, 3)` | `base` to the `exponent` power, as in `base^exponent` |
| SQRT | `SQRT(value1)` | `SQRT(Column)` | Outputs square root of the value | | SQRT | `SQRT(value1)` | `SQRT(Column)` | Square root of the input parameter |
| ABS | `ABS(value1)` | `ABS(Column)` | Provides absolute value of the value | | ABS | `ABS(value1)` | `ABS(Column)` | Absolute value of the input parameter |
| NOW | `NOW()` | `NOW()` | Use to get current date time | | NOW | `NOW()` | `NOW()` | Current date time |
| REPLACE | `REPLACE(value1, old_str,new_str)` | `REPLACE(Column, old_string, new_String)` | Replaces all occurrences of `old_string` with `new_String` and returns the new string | | REPLACE | `REPLACE(value1, old_str,new_str)` | `REPLACE(Column, old_string, new_String)` | String, after replacing all occurrences of `old_string` with `new_String` |
| SEARCH | `SEARCH(value1, search_val)` | `SEARCH(Column, 'str')` | Search for a string and returns the index of the string position | | SEARCH | `SEARCH(value1, search_val)` | `SEARCH(Column, 'str')` | Index of sub-string specified if found, 0 otherwise |
| INT | `INT(value1)` | `INT(Column)` | Converts the value to integer and returns | | INT | `INT(value1)` | `INT(Column)` | Integer value of input parameter |
| RIGHT | `RIGHT(value1, count)` | `RIGHT(Column, 3)` | Extracts `n` characters from the ending of string | | RIGHT | `RIGHT(value1, count)` | `RIGHT(Column, 3)` | `n` characters from the end of input parameter |
| LEFT | `LEFT(value1, [value2,...])` | `LEFT(Column, 3)` | Extracts `n` characters from the sbeginning of string | | LEFT | `LEFT(value1, [value2,...])` | `LEFT(Column, 3)` | `n` characters from the beginning of input parameter |
| SUBSTR | `SUBTR(value1, position, [count])` | `SUBSTR(Column, 3, 2)` | Extract substring from a string | | SUBSTR | `SUBTR(value1, position, [count])` | `SUBSTR(Column, 3, 2)` | Substring of length 'count' of input string, from the postition specified |
| MID | `SUBTR(value1, position, [count])` | `MID(Column, 3, 2)` | It's an alias for `SUBSTR` | | MID | `SUBTR(value1, position, [count])` | `MID(Column, 3, 2)` | Alias for `SUBSTR` |
| IF | `MIN(expression, success_case, [else_case])` | `IF(Column > 1, Value1, Value2)` | If condition satisfies it return `Value1` or it returns `Value2` | | IF | `IF(expression, success_case, [else_case])` | `IF(Column > 1, Value1, Value2)` | success_case if expression evaluates to TRUE, else_case otherwise |
| SWITCH | `MIN(expression, [pattern,value,..., default_value])` | `SWITCH(Column1, 1, 'One', 2, 'Two', '--')` | Based on pattern match it return corresponding values | | SWITCH | `SWITCH(expression, [pattern,value,..., default_value])` | `SWITCH(Column1, 1, 'One', 2, 'Two', '--')` | Switch case value based on expression output |
| AND | `AND(expression1, [expression2,...])` | `AND(Column > 2, Column < 10)` | Checks all conditions are satisfying | | AND | `AND(expression1, [expression2,...])` | `AND(Column > 2, Column < 10)` | TRUE if all expressions evaluate to TRUE |
| OR | `OR(expression1, [expression2,...])` | `OR(Column > 2, Column < 10)` | Checks at least one condition is satisfying | | OR | `OR(expression1, [expression2,...])` | `OR(Column > 2, Column < 10)` | TRUE if at least one expression evaluates to TRUE |
### Numeric Operators ### Numeric Operators
@ -52,7 +66,7 @@ menuTitle: 'Formulas'
| `+` | `column1 + column2 + 2` | Addition of numeric values | | `+` | `column1 + column2 + 2` | Addition of numeric values |
| `-` | `column1 - column2` | Subtraction of numeric values | | `-` | `column1 - column2` | Subtraction of numeric values |
| `*` | `column1 * column2` | Multiplication of numeric values | | `*` | `column1 * column2` | Multiplication of numeric values |
| `-` | `column1 / column2` | Divide numeric values | | `-` | `column1 / column2` | Division of numeric values |
### Logical operators ### Logical operators

Loading…
Cancel
Save