Browse Source

docs: refactor formats & add URL formula

Signed-off-by: Wing-Kam Wong <wingkwong.code@gmail.com>
pull/1354/head
Wing-Kam Wong 3 years ago
parent
commit
d2cbe045bd
  1. 107
      packages/noco-docs/content/en/setup-and-usages/formulas.md

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

@ -29,23 +29,22 @@ menuTitle: "Formulas"
### Numeric Functions ### Numeric Functions
| Name | Syntax | Sample | Output | | Name | Syntax | Sample | Output |
| ----------- | ------------------------------------------- | ----------------------------------------- | ---------------------------------------------- | |-------------|----------------------------|----------------------------------|------------------------------------------------------------------|
| **ABS** | `ABS(value)` | `ABS(Column)` | Absolute value of the input parameter | | **ABS** | `ABS(value)` | `ABS(Column)` | Absolute value of the input parameter |
| **ADD** | `ADD(value1,[value2,...])` | `ADD(Column1, Column1)` | Sum of input parameters &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; | | **ADD** | `ADD(value1,[value2,...])` | `ADD(Column1, Column1)` | Sum of input parameters |
| **AVG** | `AVG(value1,[value2,...])` | `AVG(Column1, Column1)` | Average of input parameters &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; | | **AVG** | `AVG(value1,[value2,...])` | `AVG(Column1, Column1)` | Average of input parameters |
| **CEILING** | `CEILING(value)` | `CEILING(Column)` | Rounded next largest integer value of input parameter | | **CEILING** | `CEILING(value)` | `CEILING(Column)` | Rounded next largest integer value of input parameter |
| **EXP** | `EXP(value)` | `EXP(Column)` | Exponential value of input parameter (`e^x`) | | **EXP** | `EXP(value)` | `EXP(Column)` | Exponential value of input parameter (`e^x`) |
| **FLOOR** | `FLOOR(value)` | `FLOOR(Column)` | Rounded largest integer less than or equal to input parameter | | **FLOOR** | `FLOOR(value)` | `FLOOR(Column)` | Rounded largest integer less than or equal to input parameter |
| **INT** | `INT(value)` | `INT(Column)` | Integer value of input parameter &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; | | **INT** | `INT(value)` | `INT(Column)` | Integer value of input parameter |
| **LOG** | `LOG([base], value)` | `LOG(10, Column)` | Logarithm of input parameter to the base (default = e) specified | | **LOG** | `LOG([base], value)` | `LOG(10, Column)` | Logarithm of input parameter to the base (default = e) specified |
| **MAX** | `MAX(value1,[value2,...])` | `MAX(Column1, Column2, Column3)` | Maximum value amongst input parameters | | **MAX** | `MAX(value1,[value2,...])` | `MAX(Column1, Column2, Column3)` | Maximum value amongst input parameters |
| **MIN** | `MIN(value1,[value2,...])` | `MIN(Column1, Column2, Column3)` | Minimum value amongst input parameters | | **MIN** | `MIN(value1,[value2,...])` | `MIN(Column1, Column2, Column3)` | Minimum value amongst input parameters |
| **MOD** | `MOD(value1, value2)` | `MOD(Column, 2)` | Remainder after integer division of input parameters | | **MOD** | `MOD(value1, value2)` | `MOD(Column, 2)` | Remainder after integer division of input parameters |
| **POWER** | `POWER(base, exponent)` | `POWER(Column, 3)` | `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` |
| **ROUND** | `ROUND(value)` | `ROUND(Column)` | Nearest integer to the input parameter | | **ROUND** | `ROUND(value)` | `ROUND(Column)` | Nearest integer to the input parameter |
| **SQRT** | `SQRT(value)` | `SQRT(Column)` | Square root of the input parameter &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; | | **SQRT** | `SQRT(value)` | `SQRT(Column)` | Square root of the input parameter |
| &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; | &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; | &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; | &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |
### Numeric Operators ### Numeric Operators
@ -63,21 +62,21 @@ menuTitle: "Formulas"
### String Functions ### String Functions
| Name | Syntax | Sample | Output | | Name | Syntax | Sample | Output |
| ------- | --------------------------------| ----------------------------------| ------------------------------------------------------------------------- | |-------------|----------------------------------|---------------------------------|---------------------------------------------------------------------------|
| **CONCAT** | `CONCAT(str1, [str2,...])` | `CONCAT(fName, ' ', lName)` | Concatenated string of input parameters | | **CONCAT** | `CONCAT(str1, [str2,...])` | `CONCAT(fName, ' ', lName)` | Concatenated string of input parameters |
| **LEFT** | `LEFT(str1, [str2,...])` | `LEFT(Column, 3)` | `n` characters from the beginning of input parameter | | **LEFT** | `LEFT(str1, [str2,...])` | `LEFT(Column, 3)` | `n` characters from the beginning of input parameter |
| **LEN** | `LEN(str)` | `LEN(Title)` | Input parameter charachter length &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; | | **LEN** | `LEN(str)` | `LEN(Title)` | Input parameter character length |
| **LOWER** | `LOWER(str)` | `LOWER(Title)` | Lower case converted string of input parameter | | **LOWER** | `LOWER(str)` | `LOWER(Title)` | Lower case converted string of input parameter |
| **MID** | `SUBTR(str, position, [count])` | `MID(Column, 3, 2)` | Alias for `SUBSTR` &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; | | **MID** | `SUBTR(str, position, [count])` | `MID(Column, 3, 2)` | Alias for `SUBSTR` |
| **REPEAT** | `REPEAT(str, count)` | `REPEAT(Column, 2)` | Specified copies of the input parameter string concatenated together | | **REPEAT** | `REPEAT(str, count)` | `REPEAT(Column, 2)` | Specified copies of the input parameter string concatenated together |
| **REPLACE** | `REPLACE(str, srchStr, rplcStr)`| `REPLACE(Column, 'int', 'num')` | String, after replacing all occurrences of `srchStr` with `rplcStr` | | **REPLACE** | `REPLACE(str, srchStr, rplcStr)` | `REPLACE(Column, 'int', 'num')` | String, after replacing all occurrences of `srchStr` with `rplcStr` |
| **RIGHT** | `RIGHT(str, count)` | `RIGHT(Column, 3)` | `n` characters from the end of input parameter | | **RIGHT** | `RIGHT(str, count)` | `RIGHT(Column, 3)` | `n` characters from the end of input parameter |
| **SEARCH** | `SEARCH(str, srchStr)` | `SEARCH(Column, 'str')` | Index of `srchStr` specified if found, 0 otherwise | | **SEARCH** | `SEARCH(str, srchStr)` | `SEARCH(Column, 'str')` | Index of `srchStr` specified if found, 0 otherwise |
| **SUBSTR** | `SUBTR(str, position, [count])` | `SUBSTR(Column, 3, 2)` | Substring of length 'count' of input string, from the postition specified | | **SUBSTR** | `SUBTR(str, position, [count])` | `SUBSTR(Column, 3, 2)` | Substring of length 'count' of input string, from the postition specified |
| **TRIM** | `TRIM(str)` | `TRIM(Title)` | Remove trailing and leading whitespaces from input parameter | | **TRIM** | `TRIM(str)` | `TRIM(Title)` | Remove trailing and leading whitespaces from input parameter |
| **UPPER** | `UPPER(str)` | `UPPER(Title)` | Upper case converted string of input parameter | | **UPPER** | `UPPER(str)` | `UPPER(Title)` | Upper case converted string of input parameter |
| &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; | &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; | &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; | &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; | | **URL** | `URL(str)` | `URL(Column)` | Convert to a hyperlink if it is a valid URL |
### Logical Operators ### Logical Operators
@ -92,23 +91,29 @@ menuTitle: "Formulas"
### Conditional Expressions ### Conditional Expressions
| Name | Syntax | Sample | Output |
| ------- | -----------------------------------------------| --------------------------------------------| ------------------------------------------------------------- | | Name | Syntax | Sample | Output |
| **IF** | `IF(expr, successCase, [failCase])` | `IF(Column > 1, Value1, Value2)` | successCase if `expr` evaluates to TRUE, elseCase otherwise | |------------|------------------------------------------------|---------------------------------------------|-------------------------------------------------------------|
| **SWITCH** | `SWITCH(expr, [pattern, value, ..., default])` | `SWITCH(Column1, 1, 'One', 2, 'Two', '--')` | Switch case value based on `expr` output | | **IF** | `IF(expr, successCase, [failCase])` | `IF(Column > 1, Value1, Value2)` | successCase if `expr` evaluates to TRUE, elseCase otherwise |
| **AND** | `AND(expr1, [expr2,...])` | `AND(Column > 2, Column < 10)` | TRUE if all `expr` evaluate to TRUE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; | | **SWITCH** | `SWITCH(expr, [pattern, value, ..., default])` | `SWITCH(Column1, 1, 'One', 2, 'Two', '--')` | Switch case value based on `expr` output |
| **OR** | `OR(expr1, [expr2,...])` | `OR(Column > 2, Column < 10)` | TRUE if at least one `expr` evaluates to TRUE | | **AND** | `AND(expr1, [expr2,...])` | `AND(Column > 2, Column < 10)` | TRUE if all `expr` evaluate to TRUE |
| &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; | &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; | &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; | &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; | | **OR** | `OR(expr1, [expr2,...])` | `OR(Column > 2, Column < 10)` | TRUE if at least one `expr` evaluates to TRUE |
Logical operators, along with Numerical operators can be used to build conditional `expressions`.
> Logical operators, along with Numerical operators can be used to build conditional `expressions`.
> Examples:
> Example:
> **IF** (marksSecured > 80, "GradeA", "GradeB") ```bash
> **SWITCH** (quarterNumber, IF(marksSecured > 80, "GradeA", "GradeB")
> 1, 'Jan-Mar', ```
> 2, 'Apr-Jun',
> 3, 'Jul-Sep', ```bash
> 4, 'Oct-Dec', SWITCH(quarterNumber,
> 'INVALID') 1, 'Jan-Mar',
2, 'Apr-Jun',
3, 'Jul-Sep',
4, 'Oct-Dec',
'INVALID'
)
```

Loading…
Cancel
Save