Open main menu

TaticView β

Changes

Expressions

1,944 bytes added, 19:07, 22 November 2019
Marked this version for translation
<translate>
<!--T:68-->
<div class="index-right">__TOC__</div>
<!--T:69-->
You can create expressions (formulas) directly in the dashboard components. It can thus display calculated values that are not present in the data source file/spreadsheet.
<!--T:70-->
To create the expression (formula) in the components, the component must support the addition of the special column ''Expression (Formula)''.
<!--T:71-->
In TaticView , all columns in the data file can be used in expressions as long as they are also added to the component that will receive the expression.
<!--T:72-->
In addition, it is also possible to use fixed numbers and texts in the case of comparative expressions.
<!--T:73-->
Expression Example:
<!--T:74-->
* If the component has the columns ''Total Price'' and ''Quantity'', you can create an expression to calculate the ''Unit Price''. Would be like this:
** ''Total Price'' / ''Quantity''
<!--T:75-->
We just remember that currently TaticView only supports expressions whose numeric return.
<!--T:76-->
Below are details about how the expressions work:
== Basic structure of a Expression (Formula) ==<!--T:77-->
==== Value Operand ====<!--T:78-->
<!--T:79-->
It's the numerical values. You can use both while values and decimal values. For decimal values, the decimal separator should be the point.
<!--T:80-->
* Examples: 1, 1.05, 2.55
==== Text Operand ====<!--T:81-->
<!--T:82-->
It's the text operands. If you want to use this type of operand in a expression, you must delimit them by the single quotation mark (').
<!--T:83-->
* Examples: 'John Snow', 'California', 'Spaghetti'
==== Date Operand ====<!--T:84-->
<!--T:85-->
These are values that express any date. To represent a date in expressions the behaviour is similar to text operands, i.e. the content must be surrounded by single quotation marks ('). However, the mask ''dd/MM/yyyy'' must be used.
<!--T:86-->
* Examples: '01/01/2019', '14/11/2019', '25/12/2019'
==== Boolean Operand ====<!--T:87-->
<!--T:88-->
They're operators of the true or false type. Normally user to validate, or not, a condition in a more complex expression.
<!--T:89-->
* Examples: true, false
==== Parentheses ====<!--T:90-->
<!--T:91-->
Used to group and separate parts of on expression. Expressions within parentheses are processed first.
<!--T:92-->
* Example: ("Profit"/"Total Price") + 10
==== System variable Operand ====<!--T:93-->
<!--T:94-->
These are predefined variables in the system. To use the system variables you must precede them by hashtag (#) and delimit them by double quotes("). Currently only the "#null" variable is available and indicates null content.
<!--T:95-->
* Example: IF("Product" == "#null";0;20)
== Arithmetic Expressions ==<!--T:96-->
<!--T:97-->
Arithmetic expressions relate two operands (which can be any the operands described above, or another expression) to make up the sum, subtraction, multiplication or division.
==== Sum (+) ====<!--T:98-->
<!--T:99-->
Add two value operands or another expression result. Represented by the ''+'' charecter.
<!--T:100-->
Syntax:
<operating or expression result> '''+''' <operating or expression result>
==== Subtraction (-) ====<!--T:101-->
<!--T:102-->
Subtract two value operands or another expression result. Represented by the ''-'' charecter.
<!--T:103-->
Syntax:
<operating or expression result> '''-''' <operating or expression result>
==== Multiplication (*) ====<!--T:104-->
<!--T:105-->
Multiplies two value operands or another expression result. Represented by the multiplication charecter ''*''.
<!--T:106-->
Syntax:
<operating or expression result> '''*''' <operating or expression result>
==== Division (/) ====<!--T:107-->
<!--T:108-->
Divide two value operands or another expression result. Represented by the division charecter ''/''.
<!--T:109-->
Syntax:
<operating or expression result> '''/''' <operating or expression result>
== Relational Expressions ==<!--T:110-->
<!--T:111-->
Relational expressions compare two operands (value/text or other expression) to assess whether a condition is true or false. Normally used with decision functions, such as ''IF''.
==== Equality (==) ====<!--T:112-->
<!--T:113-->
It compares if two operands are the same, returning true if they are the same or false if they are different. Represented by the equality operator ''==''.
<!--T:114-->
Syntax:
<operating or expression result> '''==''' <operating or expression result>
==== Different (!=) ====<!--T:115-->
<!--T:116-->
It compare if two operands are different, returning true if they were different or false if equal. Represented by the differente operator ''!=''.
<!--T:117-->
Syntax:
<operating or expression result> '''!=''' <operating or expression result>
==== Greater than (>) ====<!--T:118-->
<!--T:119-->
Compares if the first operator (from the left) is greater than the second operator (from the right), returning true if it is greater and false if it is lesser or equal. Represented by the greater operator ''>''.
<!--T:120-->
Syntax:
<operating or expression result> '''>''' <operating or expression result>
==== Greater or equal to (>=) ====<!--T:121-->
<!--T:122-->
Compares if the first operator (from the left) is greater or equal to the second operator (from the right), returning true if it is greater or equal and false if it is lesser. Represented by the greater or equal operator ''>=''.
<!--T:123-->
Syntax:
<operating or expression result> '''>=''' <operating or expression result>
==== Less than (<) ====<!--T:124-->
<!--T:125-->
Compares if teh first operator (from the left) is lesser than the second operator (from the right), returning true if it is lesser and false if it is greater or equal. Represented by the Lesser operator ''<''.
<!--T:126-->
Syntax:
<operating or expression result> '''<''' <operating or expression result>
==== Less or equal to (<=) ====<!--T:127-->
<!--T:128-->
Compares if the first operator (from the left) is lesser or equal to the second operator (from the right), returning true if it is lesser or equal and false if it is greater. Represented by the lesser or equal operator ''<=''.
<!--T:129-->
Syntax:
<operating or expression result> '''<=''' <operating or expression result>
== Logical Expressions ==<!--T:130-->
<!--T:131-->
Logical expressions group together two operands (Boolean or other expression) to make up a logical expression, in order to evaluate the relationship of two Boolean operators to a true or false result. This type of expression is usually used for decision making, such as IF and with relational expressions.
==== And Operator (&&) ====<!--T:132-->
<!--T:133-->
Executes the logical operation ''AND'' between two Boolean values. Both values must return true so that the result of the operation is true. Represented by the ''&&'' operator.
<!--T:134-->
Syntax:
<expression> && <expression>
==== Or Operator (||) ====<!--T:135-->
<!--T:136-->
Performs the logical ''OR'' operation between two Boolean values. A two values must be true so that the result of the operation is true. Represented by the operator ''||''.
<!--T:137-->
Syntax:
<expression> || <expression>
'''IF(("Price" > 1000) || ("Profit" >= 50);75;55)''' - If ''Price'' is greater than ''1000'' '''OR''' ''Profit'' is greater than or equal to ''50'' returns ''75'' if not ''55''
<!--T:138-->'''IF(("City" != "#null") || ("Product" != 'Lasagna');1;0)''' - If ''City'' is non-null '''OR''' ''Product'' is different from ''Lasagna'' returns ''1'' if it does not return ''0''
==== Denial Operator (!) ====<!--T:139-->
<!--T:140-->
Performs the logical negation operation for a boolean value. If the result of the operation is true the negation operator converts to false and vice versa. Represented by the operator ''!''.
<!--T:141-->
Syntax:
!<expression>
== Auxiliary Functions ==<!--T:142-->
<!--T:143-->
Basic helper functions are standard system functions and implement useful features for composing complex expressions.
==== ABS function ====<!--T:144-->
<!--T:145-->
Function that returns the absolute numeric value of a base numeric value.
<!--T:146-->
Syntax:
ABS(<value operator or expression>)
==== AVG function ====<!--T:147-->
<!--T:148-->
Returns the average of the values ​​of a sequence of values. It can be used to return the average of different values ​​of the same row of tables.
<!--T:149-->
Syntax:
AVG(<expression 1>; <expression 2>; ...)
==== BETWEEN function ====<!--T:150-->
<!--T:151-->
Checks whether a value is within the limits of the parameters used. Return true or false.
<!--T:152-->
Syntax:
BETWEEN(<expression to be tested>; <initial limit>; <end limit>)
==== IF ELSE function (If .... Otherwise ...) ====<!--T:153-->
<!--T:154-->
Tests a Boolean expression and applies a condition to true or another condition to false. You need three parameters, separated by semicolons (;). The first parameter is the expression to be tested, the second the value to be applied in case of true, and the third to be applied in case of false.
<!--T:155-->
Syntax:
IF(<expression to be tested>; <expression if true>; <expression if false>)
'''IF(BETWEEN("Value";0;100);10;250)''' - If ''Value'' is between ''0'' and ''100'' returns ''10'', if not ''250''
<!--T:156-->'''IF("Profit" == 0;0;"Profit" + "Taxes")''' - If ''Profit'' equals ''0'' returns ''0'', if it does not return the sum between ''Profit'' and ''Taxes''
==== LOG function ====<!--T:157-->
<!--T:158-->
Returns the logarithm of a number on a defined basis. It can be used with only one parameter, in this case the neperian (natural) logarithm is used . If two parameters are used, the second server to inform the base to be used by the logarithm.
<!--T:159-->
Syntax:
LOG(<expression>;<base>)
'''LOG("Profit")'''- Returns the logarithm of the field ''Profit''
<!--T:160-->'''LOG("Price";2)''' - Returns the logarithm of the ''Price'' field in base ''2''
==== MAX function ====<!--T:161-->
<!--T:162-->
Returns the largest value between two values.
<!--T:163-->
Syntax:
MAX(<expression 1>;<expression 2>)
==== MIN function ====<!--T:164-->
<!--T:165-->
Returns the smallest value between two values.
<!--T:166-->
Syntax:
MIN(<expression 1>; <expression 2>)
==== POWER function ====<!--T:167-->
<!--T:168-->
Returns the power of a value in a defined exponent. It can be used with only one parameter, in this case it considers the default exponent 2. If a second parameter is passed, this will be the exponent.
<!--T:169-->
Syntax:
POW(<expression>; <exponent>)
'''POW("Profit")''' - Returns the power of the ''Profit'' value.
<!--T:170-->'''POW("Cost"; 3)''' - Returns the power of the ''Cost'' value, raised to ''3''
==== RANDOM function ====<!--T:171-->
<!--T:172-->
Returns a random number within the range of values ​​passed as arguments.
<!--T:173-->
Syntax:
RANDOM(<start limit>; <end limit>)
==== SQRT function (Square Root) ====<!--T:174-->
<!--T:175-->
Returns the square root of a value.
<!--T:176-->
Syntax:
SQRT(<value or expression>)
'''SQRT("Profit")''' - Returns the square root of the value ''Profit''
<!--T:177-->'''SQRT(81)''' - Returns the square root of ''81''
==== LIKE function ====<!--T:178-->
<!--T:179-->
Returns true if the desired content is found in the list and false otherwise. It needs two parameters, the first is the data to query and the second is the term to be found. Remembering that it is necessary to use the wildcard operator “%” and surround the term by single quotation mark.
<!--T:180-->
Syntax:
LIKE(< data>; <term>)
== Date Functions ==<!--T:181-->
<!--T:182-->
Date functions are operations that take a date as a parameter and also return a date. There are some constants to assist in using date functions, they are:
<!--T:183-->
* 0: ''DATE_FIELD_YEAR'' (Part of the year)
* 1: ''DATE_FIELD_MONTH'' (Month Part)
==== DATE_PART function (Date Part) ====<!--T:184-->
<!--T:185-->
Returns part of a date. It needs two parameters, the first is the reference date and the second is the constant that represents which part of the date we want to get.
<!--T:186-->
Syntax:
DATE_ PART(<date>; <constant representing which part>)
==== DAY_FROM_TODAY function (Days from today) ====<!--T:187-->
<!--T:188-->
Returns a days count backward (negative) or forward (positive) from today. You need a parameter that indicates the number of days to add or subtract.
<!--T:189-->
Syntax:
DAY_FROM_TODAY(<number of days>)
==== FIRST_DAY_OF function (First day of) ====<!--T:190-->
<!--T:191-->
Returns the first day of a grouping. This function has two variations:
<!--T:192-->
* With two parameters, the first is the grouping constant from which we want to get the first date (see list above), and the second is the base date.
<!--T:193-->
Syntax:
FIRST_DAY_OF(<date part>; <base date>)
'''FIRST_DAY_OF(0;DAY_FROM_TODAY(0))''' - Returns the first day of the year from today
<!--T:194-->'''FIRST_DAY_OF(1;"Issue Date")''' - First Day of Month Based on ''Issue Date'' Column
<!--T:195-->
* With three parameters, the first is the grouping constant from which we want to get the first date (see list above), the second is the date base modifier from today, and the third is the amount to change the modifier.
<!--T:196-->
Syntax:
FIRST_DAY_OF(<date part>;<date modifier>;<date modifier value>)
==== LAST_DAY_OF function (Last day of) ====<!--T:197-->
<!--T:198-->
Returns the last day of a date grouping. This function has two variations.
<!--T:199-->
* With two parameters, the first is the grouping constant from which we want the last date (see list above), and the second is the base date.
<!--T:200-->
Syntax:
LAST_DAY_OF(<date part>; <base date>)
'''LAST_DAY_OF(0;DAY_FROM_TODAY(0))''' - Returns the last day of the year from today.
<!--T:201-->'''LAST_DAY_OF(1;"Date Issued")''' - Last day of month based on ''Date Issued'' column
<!--T:202-->
* With three parameters, the first is the grouping constant from which we want the last date (see list above), the second is the date base modifier from today, and the third is the amount to change the modifier.
<!--T:203-->
Syntax:
LAST_DAY_OF(<date part>;<date modifier>;<date modifier value>)
==== NEW_DATE function (New date) ====<!--T:204-->
<!--T:205-->
Creates a new date. It needs three parameters, the first corresponds to the day (between 1 and 31), the second month (between 1 and 12) and the third the year. The date is created from year to day, ie the day must be valid for the month and year (considering 29/02, the year must be leap).
<!--T:206-->
Syntax:
NEW_DATE(<day>;<month>;<year>)
==== NUM_OF_DAYS function (Number of days) ====<!--T:207-->
<!--T:208-->
Returns the number of days between two dates. Therefore you need two dates.
<!--T:209-->
Syntax:
NUM_OF_DAYS(<date 1>; <date 2>)
'''NUM_OF_DAYS(FIRST_DAY_OF(0;"Issued Date");"Issued Date")''' - Returns the number of days from the first day of the year, based on the ''Issued Date'' column, to the current day, based on the same column.
<!--T:210-->'''NUM_OF_DAYS(FIRST_DAY_OF(1;"Issued Date");LAST_DAY_OF(1,"Issued Date"))''' - Returns the number of days of the month, based on the ''Issued Date'' column.
==== NUM_OF_MONTHS function (Number of months) ====<!--T:211-->
<!--T:212-->
Returns the number of months between two dates. Therefore, two date parameters are required.
<!--T:213-->
Syntax:
NUM_OF_MONTHS(<date 1>; <date 2>)
==== PREVIOUS_DATE function (Previous date) ====<!--T:214-->
<!--T:215-->
Given a day and a month, returns the last occurrence of that date. That is, if the current date (today) is less than the date passed by parameter (day / month), the return is the date (passed by parameter) of the previous year. Otherwise the return will be the current year date.
<!--T:216-->
Syntax:
PREVIOUS_DATE(<day>; <month>)
== Special Variables ==<!--T:217-->
<!--T:218-->
They can be used in conjunction with expressions to create complex calculations. Must be used in double quotation marks (“)
<!--T:219-->
* '''"@count"''' - Total number of rows that were returned for the component.
* '''"@row"''' - Current row number