Difference between revisions of "Expressions"

From TaticView
Jump to: navigation, search
(Marked this version for translation)
 
(70 intermediate revisions by 5 users not shown)
Line 1: Line 1:
Expressions allows to manually create and edit [[Filters]] rules by using programming language. '''Important''': After manually editing the expression the others operators cannot be used until you clear all the filters;
+
<languages/>
  
  
__TOC__
+
<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 datasource file/spreadsheet.
  
== Basic Expression Structures ==
 
  
=== Value Operands ===
+
<!--T:70-->
 +
To create the expression (formula) in the components, the component must support the addition of the special column ''Expression (Formula)''.
  
  
The value operands are values from a [[Columns Data Type|data type]] that are used in expressions as variables.
+
<!--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.
  
  
* '''Value type operand''': Are numeric values of the float type (Real numbers domain). These values allow the use of a integer and a fraction part, separated by the dot (.) character (decimal separator). Examples: 1, 1.05, 2.55;
+
<!--T:72-->
 +
In addition, it is also possible to use fixed numbers and texts in the case of comparative expressions.
  
* '''Text type operand''': Are literal string data operands. These values allow the use of characters chain fields (strings), being delimited by the simple quote (') character. Examples: 'John Snow', 'California', 'Spaghetti';
 
  
* '''Date type operand''': Are values that express any date. It is possible to determine a date representing it as a string, being delimited by the simple quote (') character and separated by the bar (/) character. The default supported format is "dd/MM/yyyy". Examples: '01/01/2011', '29/02/2000';
+
<!--T:73-->
 +
Expression Example:
  
* '''Boolean type operand''': Are values from the ''true'' or ''false'' kind. Usually used to validate or not a condition. Examples: true e false;
+
<!--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"''
 +
* In addition, you can use fixed values, such as:
 +
** ''"Total price"'' / 10
  
* '''Identifier type operand''': Are values that represents a field or variable in the expression. Used to make reference to data source columns, delimited by double quotes ("). Examples: "City.City", "Product.Product";
 
  
* '''System variable type operand''': Are system pre-defined variables. These values are replaced in run-time by pre-determined values, delimited by double quotes (") and preceded by star (#). By now only one variable is available: "#null" that indicates null values or fields.
+
<!--T:75-->
 +
We just remember that currently TaticView only supports expressions whose numeric return.
  
  
=== Arithmetic Expressions ===
+
<!--T:225-->
 +
Expressions support the backslash as [[EscapeChar|escape character]] so that names can contain the delimiting characters.
  
 +
<!--T:76-->
 +
Below are details about how the expressions work:
  
The arithmetic expressions relate two operands (value or another expression) to compose a sum, subtraction, multiplication or division.
+
== Basic structure of a Expression (Formula) == <!--T:77-->
  
 +
==== Identifier ==== <!--T:226-->
  
* '''Sum (+)''': Sum two operands. Represented by the sum (+) character. The expression syntax is ''<operand/expression> + <operand/expression>''. Examples: "Taxes" + "Commissions";
+
<!--T:227-->
 +
It is the name of the field or column involved in the expression, it must be delimited by double quotes.
  
* '''Subtraction (-)''': Subtract two operands. Represented by the subtract or hyphen (-) character. The expression syntax is ''<operand/expression> - <operand/expression>''. Examples: "Gross Sale" - "Taxes";
+
<!--T:228-->
 +
* Examples: "Average Price". "Screw 1\" philips", "Seler"
  
* '''Multiplication (*)''': Multiplicate two operands. Represented by the multiplication or star (*) character. The expression syntax is ''<operand/expression> * <operand/expression>''. Examples: "Amount" * "Unit Price";
+
==== Value Operand ==== <!--T:78-->
  
* '''Division(/)''': Divides two operands. Represented by the divide or bar (/) character. The expression syntax is ''<operand/expression> / <operand/expression>''. Examples: "Total Value" / "Amount".
+
<!--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
  
=== Expressões relacionais ===
+
<!--T:220-->
 +
* Important: Do not use thousand separator in numeric values.
  
 +
==== Text Operand ==== <!--T:81-->
  
São elementos de expressão que relacionam dois operandos (de qualquer tipo ou de outra expressão) para compor uma expressão relacional, cujo o objetivo é avaliar dois operandos e resultar um resultado verdadeiro ou falso da relação entre os dois. Expressões relacionais são: igual (==), diferente (!=) maior que (>), menor que (<), maior ou igual a (>=) e menor ou igual a (<=). Geralmente, utilizadas em funções de decisão, como IF.
+
<!--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 (').
  
* '''Igual (==)'''
+
<!--T:83-->
        Realiza a operação de comparação de igualdade entre dois operandos. Representada pelos operador igual (==). A sintaxe da expressão é: <expressão> == <expressão>
+
* Examples: 'John Snow', 'California', 'Spaghetti'
        Exemplos: "F12_01" == "F12_02", "F12_01" == "F14_01", "F12_01" == 100.0, ("F12_01" - "F12_02") == "F14_01".
 
  
* '''Diferente (!=)'''
 
        Realiza a operação de comparação de diferença entre dois operandos. Representada pelos operador diferente (!=). A sintaxe da expressão é: <expressão> != <expressão>
 
        Exemplos: "F12_01" != "F12_02", "F12_01" != "F14_01", "F12_01" != 100.0, ("F12_01" - "F12_02") != "F14_01".
 
  
* '''Maior que (>)'''
+
==== Date Operand ==== <!--T:84-->
        Retorna o resultado da comparação do primeiro operando em relação ao segundo, no caso se o primeiro é maior que o segundo. Representada pelo operador maior (>). A sintaxe da expressão é: <expressão> > <expressão>
 
        Exemplos:IF("Data" > '01/01/2011';F12_01;0), IF(F12_01 > "@avg[F12_01]";'Acima';'Abaixo').
 
  
* '''Menor que (<)'''
+
<!--T:85-->
        Retorna o resultado da comparação do primeiro operando em relação ao segundo, no caso se o primeiro é menor que o segundo. Representada pelo operador menor (<). A sintaxe da expressão é: <expressão> < <expressão>
+
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.
        Exemplos:IF("Data" < DAY_FROM_TODAY(0);F12_01;0), IF(F12_01 < 1;1;F12_01).
 
  
* '''Maior ou igual a (>=)'''
+
<!--T:86-->
        Retorna o resultado da comparação do primeiro operando em relação ao segundo, no caso se o primeiro é maior ou igual ao segundo. Representada pelo operador maior-ou-igual(>=). A sintaxe da expressão é: <expressão> >= <expressão>
+
* Examples: '01/01/2019', '14/11/2019', '25/12/2019'
        Exemplos:IF("Data" >= '01/01/2011';F12_01;0), IF(F12_01 >= "@avg[F12_01]";'Acima';'Abaixo').
 
  
* '''Menor ou igual a (<=)'''
 
        Retorna o resultado da comparação do primeiro operando em relação ao segundo, no caso se o primeiro é menor ou igual ao segundo. Representada pelo operador menor-ou-igual(<=). A sintaxe da expressão é: <expressão> <= <expressão>
 
        Exemplos:IF("Data" <= DAY_FROM_TODAY(0);F12_01;0), IF(F12_01 <= 1;1;F12_01).
 
  
 +
==== Boolean Operand ==== <!--T:87-->
  
=== Expressões lógicas ===
+
<!--T:88-->
 +
They're operators of the true or false type. Normally user to validate, or not, a condition in a more complex expression.
  
São elementos de expressão que agrupam dois operandos (do tipo booleano ou de outra expressão) para compor uma expressão lógica, cujo o objetivo é avaliar dois operandos booleanos num resultado verdadeiro ou falso da relação entre os dois. Expressões lógicas suportadas são: and (&&), or (||) e not (!). Geralmente, utilizadas em funções de decisão, como IF e em conjunto com expressões relacionais.
+
<!--T:89-->
 +
* Examples: true, false
  
* '''And (&&)'''
 
        Realiza a operação lógica de AND entre dois valores booleanos. Assim, os dois operandos devem ser verdadeiros para que o resultado da expressão seja verdadeiro. Representada pelos operador and (&&). A sintaxe da expressão é: <expressão> && <expressão>
 
        Exemplos: IF(BETWEEN("Data", '01/01/2011', '31/12/2011') && (Vendedor == 'Fulano');F12_01;0), IF((F12_01!="#null") && (Data<DAY_FROM_TODAY(0));1;0).
 
  
* '''Or (||)'''
+
==== Parentheses ==== <!--T:90-->
        Realiza a operação lógica de OR entre dois valores booleanos. Assim, se um dos dois operandos é verdadeiro o resultado da expressão será verdadeiro. Representada pelos operador or (||). A sintaxe da expressão é: <expressão> || <expressão>
 
        Exemplos: IF(BETWEEN("Data", '01/01/2011', '31/12/2011') || (Vendedor == 'Fulano');F12_01;0), IF((F12_01!="#null") || (Data<DAY_FROM_TODAY(0));1;0).
 
  
* '''Not (!)'''
+
<!--T:91-->
        Realiza a operação lógica de negação para um valor booleano. Assim, se o operador está verdadeiro, o not converte para falso (e vice-versa). Representada pelos operador not (!). A sintaxe da expressão é: ! <expressão>
+
Used to group and separate parts of on expression. Expressions within parentheses are processed first.
        Exemplos: IF(!BETWEEN("Data", '01/01/2011', '31/12/2011');F12_01;0).
 
  
 +
<!--T:92-->
 +
* Example: ("Profit"/"Total Price") + 10
  
== Funções Auxiliares ==
 
  
As funções são tipos de elementos de expressão (ou seja operandos) que permitem que se execute qualquer computação possível sobre uma expressão, desde que, é claro, se implemente uma classe para cada objetivo. Atualmente, o framework de expressões possui diversas expressões implementadas. Elas são categorizadas em "Funções Básicas" e "Funções de Data".
+
==== System variable Operand ==== <!--T:93-->
  
Uma questão importante sobre as funções é que elas possuem parâmetros. Estes parâmetros possuem tipo e quantidade coerentes com a operação que a função implementa e, portanto, deve-se respeitar a ordem e os tipos de dados destes parâmetros para que a função funcione corretamente. Toda função possui uma identificação da sua operação principal e, dentro de parênteses, uma lista de parâmetros separados por ponto-e-vírgula (;). É possível também que uma função não tenha parâmetros. Sintaxe padrão das funções: nome_da_funcao([param1[;param2;...;paranN]]).
+
<!--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)
  
=== Funções Básicas ===
+
== 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.
  
São funções padrão do sistema e implementam operações utilitárias básicas e a funcionalidade de alguns comandos de programação.
 
  
* '''Abs'''
+
==== Sum (+) ==== <!--T:98-->
        Retorna o valor absoluto de um valor base. Sintaxe: ABS(<expressão>)
 
        Aceita apenas um parâmetro e o tipo de dados que processa é um número.
 
        Exemplo: ABS(F12_01-F12_02)
 
  
* '''Avg'''
+
<!--T:99-->
        Retorna a média de uma lista de valores. Sintaxe: AVG(<expressão1>;<expressão2>[;<expressão3>;...;<expressãoN>])
+
Add two value operands or another expression result. Represented by the ''+'' charecter.
        Aceita vários parâmetros e o tipo de dados que processa é um número.
 
        Pode ser utilizada para retornar a média de valores entre colunas de uma mesma linha de uma tabela.
 
        Exemplo: ABS(F12_01;F12_02;F12_03)
 
  
* '''Between'''
+
<!--T:100-->
        Verifica de um valor está dentro dos limites de valores parametrizados. Sintaxe: BETWEEN(<expressão_a_testar>;<expressão_lim_inferior>;<expressao_lim_superior>)
+
Syntax:
        Exige exatamente três parâmetros (de qualquer tipo, desde sejam do mesmo tipo entre si) e o tipo que retorna é um booleano, verdadeiro caso o valor esteja dentro dos limites; falso, caso contrário.
+
  <operating or expression result> '''+''' <operating or expression result>
        Exemplos: BETWEEN("Data";'01/01/2011';'31/12/2011'), BETWEEN(F12_03;F12_01;F12_02)
+
Example:
 +
  '''"Taxes" + "Commissions"''' - Sums the values of the fields ''Taxes'' and ''Commissions''
  
* '''If then else'''
 
        Faz um teste sobre uma expressão booleana e retorna um valor para o caso da expressão ser verdadeira e outro para o caso dela ser falsa. Sintaxe: IF(<expressão_teste>;<expressão_para_verdadeiro>;<expressão_para_falso>).
 
        Exige exatamente três parâmetros uma expressão booleana e retorno de qualquer tipo, desde que seja o mesmo para as duas cláusulas.
 
        Muito utilizada para testes lógicos para ter duas opções de execução de uma expressão.
 
        Exemplos: IF(BETWEEN("Data";'01/01/2011';'31/12/2011');F12_01;0.0), IF("Região"=='SUL';F12_01;F12_01+F14_01), IF(F12_01==0;0;F12_01/"@sum[F12_01]")
 
  
* '''Log'''
+
==== Subtraction (-) ==== <!--T:101-->
        Calcula o logaritmo de um número numa determinada base. Sintaxe: LOG(<expressão_número>[;<expressão_base>]).
 
        No mínimo é no máximo dois parâmetros. Se apenas um elemento for passado por parâmetro, o algoritmo calcula logaritmo neperiano; caso o segundo seja informado, calcula logaritmo na respectiva base.
 
        Exemplo: LOG(F12_01)
 
  
* '''Max'''
+
<!--T:102-->
        Retorna o maior entre dois números. Sintaxe: MAX(<expressão_valor1>;<expressão_valor1>);
+
Subtract two value operands or another expression result. Represented by the ''-'' charecter.
        Exatamente dois parâmetros são exigidos. Processa elemento numéricos e retorna um número.
 
        Exemplo: F12_01/MAX(F14_01;100.0)
 
  
* '''Min'''
+
<!--T:103-->
        Retorna o menor entre dois números. Sintaxe: MIN(<expressão_valor1>;<expressão_valor1>);
+
Syntax:
        Exatamente dois parâmetros são exigidos. Processa elemento numéricos e retorna um número.
+
  <operating or expression result> '''-''' <operating or expression result>
        Exemplo: F12_01/MIN(F14_01;100.0)
+
Example:
 +
  '''"Price" - "Taxes"''' - Subtracts the values ​​from the ''Price'' and ''Taxes'' fields.
  
* '''Pow'''
 
        Calcula a operação de potenciação. Sintaxe: POW(<expressão_base>[;<expressão_expoente>])
 
        No mínimo um e no máximo dois parâmetros. Calcula a potenciação de um número dado um expoente numérico. Se este expoente não passado por parâmetro utiliza por padrão 2, portanto, executa número ao quadrado.
 
        Exemplo: POW(F12_01-F12_02)+POW(F12_03-F12_04)
 
  
* '''Random'''
+
==== Multiplication (*) ==== <!--T:104-->
        Retorna um número aleatório entre dois limites. Sintaxe: RANDOM(<expressão_lim_inferior>;<expressão_lim_superior>)
 
        Exatamente dois parâmetros, informando, respectivamente, o limite inferior e o superior do número aleatório a ser gerado.
 
        Exemplo: RANDOM(0.0;1.0)
 
  
* '''Sqrt'''
+
<!--T:105-->
        Calcula a operação de raiz quadrada. Sintaxe: SQRT(<expressão_base>)
+
Multiplies two value operands or another expression result. Represented by the multiplication charecter ''*''.
        Exatamente um parâmetro. Calcula a raiz quadrada de um número.
 
        Exemplo: SQRT(POW(F12_01-F12_02)+POW(F12_03-F12_04))
 
  
 +
<!--T:106-->
 +
Syntax:
 +
  <operating or expression result> '''*''' <operating or expression result>
 +
Example:
 +
  '''"Quantity" * "Unit Price"''' - Multiplies the value of the ''Quantity'' field by the value of the ''Unit Price'' field.
  
=== Funções de Data ===
 
  
 +
==== Division (/) ==== <!--T:107-->
  
As funções de data são operações que tomam como base parâmetros ou resultado do tipo data.
+
<!--T:108-->
 +
Divide two value operands or another expression result. Represented by the division charecter ''/''.
  
* '''Algumas constantes estão definidas assim:'''
+
<!--T:109-->
    Constante Propósito Valor definido
+
Syntax:
    DATE_FIELD_YEAR Indica a parte do ano de uma data 0
+
  <operating or expression result> '''/''' <operating or expression result>
    DATE_FIELD_MONTH Indica a parte do mês de uma data 1
+
Example:
    DATE_FIELD_DAY Indica a parte dia de uma data 2
+
  '''"Price" / "Quantity"''' - Divides the value of the ''Price'' field by the value of the ''Quantity'' field.
    DATE_FIELD_FORTNIGHT Indica a parte da quinzena de uma data 3
 
    DATE_FIELD_WEEK Indica dia da semana de uma data 5
 
  
* '''Date part'''
 
        Retorna uma parte de uma data. Sintaxe: DATE_PART(<expressão_data>;<expressão_const_parte>)
 
        Exatamente dois parâmetros, sendo que o primeiro é da data de referência e o segundo parte de interesse. Note que a parte deve ser uma das constantes numéricos definidas acima: 0, 1, 2, 3 ou 5.
 
        Exemplo: DATE_PART("Data";0) - retorna o ano da coluna "Data" da linha atual da tabela.
 
  
* '''Day from today'''
+
== Relational Expressions == <!--T:110-->
        Retorna uma data a partir de hoje e número de dias para frente ou para trás. Sintaxe: DAY_FROM_TODAY(<expressão_num_dias>)
 
        Exatamente um parâmetro, que é o número modificador para o dia de hoje.
 
        Exemplo: DAY_FROM_TODAY(-1) - retorna a data relativa a "ontem".
 
  
* '''First day of'''
+
<!--T:111-->
        Retorna o primeiro dia de um agrupamento. Sintaxe: FIRST_DAY_OF(<expressão_const_parte_agrupamento>;<expressão_data_base>) ou FIRST_DAY_OF(<expressão_const_parte_agrupamento>;<expressão_campo_mod_data_base>;<expressão_valor_mod_data_base>)
+
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''.
        Duas variações de parâmetros (2 ou 3):
 
            Se dois parâmetros são passados para a função, o primeiro é o campo do agrupamento que se está interessado em obter a primeira data (somente 0, 1, 3 ou 5). E o segundo, é data base para servir como âncora.
 
            Se três parâmetros são passados para a função, o primeiro é o campo do agrupamento que se está interessado em obter a primeira data (somente 0, 1, 3 ou 5). O segundo é campo que modifica a data base a partir de hoje (0, 1, 2, 3 ou 5) e o terceiro em quanto este campo modificador deve ser alterado.
 
        Exemplos:
 
            FIRST_DAY_OF(0;DAY_FROM_TODAY(0)) - primeiro dia do ano (0) a partir de hoje (DAY_FROM_TODAY(0)).
 
            FIRST_DAY_OF(1;"Data") - primeiro dia do mês (1) a partir da coluna "Data" da linha atual da tabela ("Data").
 
            FIRST_DAY_OF(1;0;-1) - primeiro dia do mês atual (1) no ano passado (0;-1).
 
  
* '''Last day of'''
 
        Retorna o último dia de um agrupamento. Sintaxe: LAST_DAY_OF(<expressão_const_parte_agrupamento>;<expressão_data_base>) ou LAST_DAY_OF(<expressão_const_parte_agrupamento>;<expressão_campo_mod_data_base>;<expressão_valor_mod_data_base>)
 
        Duas variações de parâmetros (2 ou 3):
 
            Se dois parâmetros são passados para a função, o primeiro é o campo do agrupamento que se está interessado em obter a primeira data (somente 0, 1, 3 ou 5). E o segundo, é data base para servir como âncora.
 
            Se três parâmetros são passados para a função, o primeiro é o campo do agrupamento que se está interessado em obter a primeira data (somente 0, 1, 3 ou 5). O segundo é campo que modifica a data base a partir de hoje (0, 1, 2, 3 ou 5) e o terceiro em quanto este campo modificador deve ser alterado.
 
        Exemplos:
 
            LAST_DAY_OF(0;DAY_FROM_TODAY(0)) - último dia do ano (0) a partir de hoje (DAY_FROM_TODAY(0)).
 
            LAST_DAY_OF(1;"Data") - último dia do mês (1) a partir da coluna "Data" da linha atual da tabela ("Data").
 
            LAST_DAY_OF(1;0;-1) - último dia do mês atual (1) no ano passado (0;-1).
 
  
* '''New date'''
+
==== Equality (==) ==== <!--T:112-->
        Cria um objeto de data a partir de um dia, um mês e um ano. Sintaxe: NEW_DATE(<expressão_dia>;<expressão_mês>;<expressão_ano>)
 
        Exatamente três parâmetros, sendo que o primeiro é um número válido para um dia (1 a 31), o segundo para um mês (1 a 12) e o terceiro é um ano. A data é criada do ano para dia, portanto, o dia deve ser válido para o mês solicitado e também considerando-se o ano no caso de 29/02 (deve ser ano bissexto).
 
        Exemplo: NEW_DATE(1;4;DATE_PART("Data";0)) - cria o dia primeiro de abril do ano determinado pela coluna "Data" da linha atual da tabela.
 
  
* '''Num of days'''
+
<!--T:113-->
        Retorna o número de dias entre duas datas. Sintaxe: NUM_OF_DAYS(<expressão_data1>;<expressão_data2>)
+
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 ''==''.
        Exatamente dois parâmetros, sendo que ambos devem ser do tipo data.
 
        Exemplos:
 
            NUM_OF_DAYS(FIRST_DAY_OF(0;"Data");"Data") - Retorna o número de dias entre o primeiro dia do ano baseado no ano da coluna "Data" está, até data da coluna "Data".
 
            NUM_OF_DAYS(FIRST_DAY_OF(1;"Data"); LAST_DAY_OF(1;"Data")) - Retorna o número de dias do mês em que a coluna "Data" está.
 
  
* '''Num of months'''
+
<!--T:114-->
        Retorna o número de meses entre duas datas. Sintaxe: NUM_OF_MONTHS(<expressão_data1>;<expressão_data2>)
+
Syntax:
        Exatamente dois parâmetros, sendo que ambos devem ser do tipo data.
+
  <operating or expression result> '''==''' <operating or expression result>
        Exemplos:
+
Example:
            NUM_OF_MONTHS(FIRST_DAY_OF(0;"Data");"Data") - Retorna o número de meses entre o primeiro dia do ano baseado no ano da coluna "Data" está, até data da coluna "Data".
+
  '''IF("Product" == "#null";0;20)''' - If the ''Product'' is null, return the value ''0''. Otherwise return the value ''20''
  
* '''Previous date'''
 
        Retorna a anterior mais próxima dado um dia e um mês. Sintaxe: PREVIOUS_DATE(<expressão_dia>;<expressão_mês>)
 
        Exatamente dois parâmetros, sendo o primeiro o dia do mês e o segundo o mês. Cabe destacar que, no caso dos parâmetros serem 29 e fevereiro, o algoritmo considerará o último dia do mês. Portanto, se o ano atual não bissexto, o dia será modificado para 28 e depois será feito cálculo de data anterior.
 
        Exemplos:
 
            PREVIOUS_DATE(1;4) - Retorna o 01/04 anterior mais próximo, ou seja, até "01/04/ano atual" retorna o "01/04/ano anterior", depois disso retorna "01/04/ano atual".
 
  
 +
==== Different (!=) ==== <!--T:115-->
  
== Exemplos ==
+
<!--T:116-->
 +
It compare if two operands are different, returning true if they were different or false if equal. Represented by the differente operator ''!=''.
  
     Alguns exemplos de expressões com operandos:
+
<!--T:117-->
        Acrescentar 5% no valor de um campo: "F12_01" * 1.05
+
Syntax:
        Retorno de valor booleano para identificar se uma data está dentro de limite máximo: "Data" <= "30/06/2011"
+
  <operating or expression result> '''!=''' <operating or expression result>
        Obter uma participação individual para uma coluna: "F12_01" / "@sum[F12_01]"
+
Example:
        Calcular uma variação percentual entre duas linhas de uma coluna: ("F12_01"-"@prev[F12_01]") / "@prev[F12_01]"
+
  '''IF("Product" != 'Lasagna';0;20)''' - If the ''Product'' is different from ''Lasagna'', return the value ''0''. Otherwise return the value ''20''
 +
 
 +
 
 +
==== 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>
 +
Example:
 +
  '''IF("Gross Value" > 1000;1;0)''' - If the ''Gross Value'' is greater than ''1000'', returns the value ''1'', if not the value ''0''
 +
 
 +
 
 +
==== 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>
 +
Example:
 +
  '''IF("Gross Value" >= 2500;100;0)''' - If ''Gross Value'' is greater than or equal to ''2500'' returns ''100'', otherwise returns ''0''
 +
 
 +
 
 +
==== 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>
 +
Example:
 +
  '''IF("Gross Value" < 100;50;200)''' - If ''Gross Value'' is less than ''100'', returns ''50'' if not ''200''
 +
 
 +
 
 +
==== 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>
 +
Example:
 +
  '''IF("Gross Value" <= 500;100;0)''' - If ''Gross Value'' is less than or equal to ''500'' returns ''100'', if not ''0''
 +
 
 +
 
 +
== 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>
 +
Examples:
 +
  '''IF(("Price" > 0) && ("Seller" == 'John Snow');450;0)''' - If ''Price'' is greater than ''0'' '''AND''' ''Seller'' is equal to ''John Snow'', returns ''450'' if not returns ''0''
 +
  '''IF(("City" != "#null") && ("Product" != 'Lasagna');1;0)''' - If ''City'' is non-null '''AND''' ''Product'' is different from ''Lasagna'' returns ''1'' if it does not return ''0''
 +
 
 +
 
 +
==== 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>
 +
Examples:
 +
  '''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''
 +
  '''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>
 +
Example:
 +
  '''IF(!BETWEEN("Delivery Date"; '01/01/2015'; '31/12/2015');2016;2015)''' - If the ''Delivery Date'' is '''NOT''' between ''01/01/2015'' and ''12/31/2015'' returns ''2016''. If between this period returns ''2015''
 +
 
 +
 
 +
== 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>)
 +
Example:
 +
  '''ABS("Price" / "Quantity")''' - Returns the absolute value of ''Price'' divided by ''Quantity''
 +
 
 +
 
 +
==== 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>; ...)
 +
Example:
 +
  '''AVG("Taxes"; "Profit"; "Cost")''' - Returns the average between the sum of the ''Taxes'', ''Profit'' and ''Cost'' columns
 +
 
 +
 
 +
==== 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>)
 +
Example:
 +
  '''BETWEEN("Date Issued"; '01/01/2019'; '31/12/2019')''' - Returns true if ''Date Issued'' is between ''01/01/2019'' and ''12/31/2019''. Otherwise returns false
 +
 
 +
==== COUNT function ==== <!--T:229-->
 +
 
 +
<!--T:230-->
 +
Returns number of occurrences (lines) for column or value.
 +
 
 +
<!--T:231-->
 +
By now this functions works only at Datasource expressions
 +
 
 +
<!--T:232-->
 +
Syntax:
 +
  COUNT(<expression>)
 +
Example:
 +
  '''COUNT("Product")''' - Returns number of occurrences (lines) of products
 +
 
 +
==== COUNT_DISTINCT function ==== <!--T:233-->
 +
 
 +
<!--T:234-->
 +
Returns number of unique occurrences (lines) for column or value.
 +
 
 +
<!--T:235-->
 +
By now this functions works only at Datasource expressions
 +
 
 +
<!--T:236-->
 +
Syntax:
 +
  COUNT_DISTINCT(<expression>)
 +
Example:
 +
  '''COUNT_DISTINCT("Product")''' - Returns number of unique (different) occurrences (lines) of products
 +
 
 +
==== 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>)
 +
Examples:
 +
  '''IF(BETWEEN("Value";0;100);10;250)''' - If ''Value'' is between ''0'' and ''100'' returns ''10'', if not ''250''
 +
  '''IF("Profit" == 0;0;"Profit" + "Taxes")''' - If ''Profit'' equals ''0'' returns ''0'', if it does not return the sum between ''Profit'' and ''Taxes''
 +
  '''IF("Product Code" == 3231;0;"Quantity" * 3;"Quantity")''' - If ''Product Code'' equals ''3231'' returns ''Quantity'' plus 3
 +
 
 +
==== 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 "base 10" 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>)
 +
Examples:
 +
  '''LOG("Profit")'''- Returns the logarithm of the field ''Profit''
 +
  '''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>)
 +
Example:
 +
  '''"Value" / MAX("Quantity";1)''' - Divides ''Value'' by the largest value between ''Quantity'' and ''1''
 +
 
 +
 
 +
==== MIN function ==== <!--T:164-->
 +
 
 +
<!--T:165-->
 +
Returns the smallest value between two values.
 +
 
 +
<!--T:166-->
 +
Syntax:
 +
  MIN(<expression 1>; <expression 2>)
 +
Example:
 +
  '''"Value" / MIN("Cost"; 100)''' - Divides ''Value'' by the smallest value between ''Cost'' and ''100''
 +
 
 +
 
 +
==== 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>)
 +
Examples:
 +
  '''POW("Profit")''' - Returns the power of the ''Profit'' value.
 +
  '''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>)
 +
Example:
 +
  '''RANDOM(10;100)''' - Returns a random number between ''10'' and ''100''
 +
 
 +
==== ROUND function ==== <!--T:222-->
 +
 
 +
<!--T:223-->
 +
Returns the rounded value of a value column or value.
 +
 
 +
<!--T:224-->
 +
Syntax:
 +
  ROUND(<value>;<precision>)
 +
Example:
 +
  '''ROUND("Profit")''' - If Profit 10.38 returns 10.00
 +
  '''ROUND(15.65)''' - Returns 16.00
 +
  '''ROUND(1.777;1)''' - Returns 1.8
 +
 
 +
==== SQRT function (Square Root) ==== <!--T:174-->
 +
 
 +
<!--T:175-->
 +
Returns the square root of a value.
 +
 
 +
<!--T:176-->
 +
Syntax:
 +
  SQRT(<value or expression>)
 +
Examples:
 +
  '''SQRT("Profit")''' - Returns the square root of the value ''Profit''
 +
  '''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>)
 +
Example:
 +
  '''LIKE("Product"; '%anh%')''' - Returns true if the ''Product'' contains the term ''anh'' or false otherwise
 +
 
 +
== 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)
 +
* 2: ''DATE_FIELD_DAY'' (Daypart)
 +
* 3: ''DATE_FIELD_FORTNIGHT'' (Part of fortnight)
 +
* 5: ''DATE_FIELD_WEEK'' (Part of the Week)
 +
 
 +
 
 +
==== 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>)
 +
Example:
 +
  '''DATE_ PART("Issued Date"; 0)''' - Returns the year portion of the ''Issued Date''
 +
 
 +
 
 +
==== 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>)
 +
Example:
 +
  '''DAY_FROM_TODAY(-1)''' - Returns yesterday's date
 +
 
 +
 
 +
==== 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>)
 +
Examples:
 +
  '''FIRST_DAY_OF(0;DAY_FROM_TODAY(0))''' - Returns the first day of the year from today
 +
  '''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>)
 +
Example:
 +
  '''FIRST_DAY_OF(1;0;-1)''' - first day of current month of last year
 +
 
 +
 
 +
==== 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>)
 +
Examples:
 +
  '''LAST_DAY_OF(0;DAY_FROM_TODAY(0))''' - Returns the last day of the year from today.
 +
  '''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>)
 +
Example:
 +
  '''LAST_DAY_OF(1;0;-1)''' - last day of current month of last year
 +
 
 +
 
 +
==== 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>)
 +
Example:
 +
  '''NEW_DATE(1;4;DATE_PART("Issued Date";0))''' - Creates the first April day of the year determined by the current row in the ''Issued Date'' column.
 +
 
 +
 
 +
==== 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>)
 +
Examples:
 +
  '''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.
 +
  '''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>)
 +
Example:
 +
  '''NUM_OF_MONTHS(FIRST_DAY_OF(0; "Date"); "Date")''' - Returns the number of months between the first day of the year and the current month, based on the ''Date'' column.
 +
 
 +
 
 +
==== 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>)
 +
Examples:
 +
  '''PREVIOUS_DATE(15;12)''' - Considering that today's date is 14/11/2019, the last time December 15th occurred relative to today's date was 15/12/2018, so this will be the return.
 +
 
 +
 
 +
== 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
 +
* '''"@sum[column]"''' - Sum of the indicated column.
 +
** Example: ''"@sum[Price]"'' - returns the sum of all rows in the ''Price'' column.
 +
* '''"@avg[column]"''' - Average column, similar to ''"@sum[column]"'' / ''"@count"''
 +
* '''"@prev[column]"''' - Row value before current row for this column
 +
* '''"@totalRowValue[column]"''' - Value of total row, (if present), from this column.
 +
* '''"@accumCol[column]"''' - Cumulative value from column to current row. Useful for calculating variable mean.
 +
** Example: ''"@accumCol[column]"'' / ''"@row"''
 +
 
 +
</translate>

Latest revision as of 02:26, 5 October 2022

Other languages:
English • ‎português do Brasil


You can create expressions (formulas) directly in the dashboard components. It can thus display calculated values that are not present in the datasource file/spreadsheet.


To create the expression (formula) in the components, the component must support the addition of the special column Expression (Formula).


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.


In addition, it is also possible to use fixed numbers and texts in the case of comparative expressions.


Expression Example:

  • 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"
  • In addition, you can use fixed values, such as:
    • "Total price" / 10


We just remember that currently TaticView only supports expressions whose numeric return.


Expressions support the backslash as escape character so that names can contain the delimiting characters.

Below are details about how the expressions work:

Basic structure of a Expression (Formula)

Identifier

It is the name of the field or column involved in the expression, it must be delimited by double quotes.

  • Examples: "Average Price". "Screw 1\" philips", "Seler"

Value Operand

It's the numerical values. You can use both while values and decimal values. For decimal values, the decimal separator should be the point.

  • Examples: 1, 1.05, 2.55
  • Important: Do not use thousand separator in numeric values.

Text Operand

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 (').

  • Examples: 'John Snow', 'California', 'Spaghetti'


Date Operand

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.

  • Examples: '01/01/2019', '14/11/2019', '25/12/2019'


Boolean Operand

They're operators of the true or false type. Normally user to validate, or not, a condition in a more complex expression.

  • Examples: true, false


Parentheses

Used to group and separate parts of on expression. Expressions within parentheses are processed first.

  • Example: ("Profit"/"Total Price") + 10


System variable Operand

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.

  • Example: IF("Product" == "#null";0;20)

Arithmetic Expressions

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 (+)

Add two value operands or another expression result. Represented by the + charecter.

Syntax:

 <operating or expression result> + <operating or expression result>

Example:

 "Taxes" + "Commissions" - Sums the values of the fields Taxes and Commissions


Subtraction (-)

Subtract two value operands or another expression result. Represented by the - charecter.

Syntax:

 <operating or expression result> - <operating or expression result>

Example:

 "Price" - "Taxes" - Subtracts the values ​​from the Price and Taxes fields.


Multiplication (*)

Multiplies two value operands or another expression result. Represented by the multiplication charecter *.

Syntax:

 <operating or expression result> * <operating or expression result> 

Example:

 "Quantity" * "Unit Price" - Multiplies the value of the Quantity field by the value of the Unit Price field.


Division (/)

Divide two value operands or another expression result. Represented by the division charecter /.

Syntax:

 <operating or expression result> / <operating or expression result>

Example:

 "Price" / "Quantity" - Divides the value of the Price field by the value of the Quantity field.


Relational Expressions

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 (==)

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 ==.

Syntax:

 <operating or expression result> == <operating or expression result>

Example:

 IF("Product" == "#null";0;20) - If the Product is null, return the value 0. Otherwise return the value 20


Different (!=)

It compare if two operands are different, returning true if they were different or false if equal. Represented by the differente operator !=.

Syntax:

 <operating or expression result> != <operating or expression result>

Example:

 IF("Product" != 'Lasagna';0;20) - If the Product is different from Lasagna, return the value 0. Otherwise return the value 20


Greater than (>)

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 >.

Syntax:

   <operating or expression result> > <operating or expression result>

Example:

 IF("Gross Value" > 1000;1;0) - If the Gross Value is greater than 1000, returns the value 1, if not the value 0


Greater or equal to (>=)

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 >=.

Syntax:

 <operating or expression result> >= <operating or expression result>

Example:

 IF("Gross Value" >= 2500;100;0) - If Gross Value is greater than or equal to 2500 returns 100, otherwise returns 0


Less than (<)

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 <.

Syntax:

 <operating or expression result> < <operating or expression result>

Example:

 IF("Gross Value" < 100;50;200) - If Gross Value is less than 100, returns 50 if not 200


Less or equal to (<=)

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 <=.

Syntax:

 <operating or expression result> <= <operating or expression result>

Example:

 IF("Gross Value" <= 500;100;0) - If Gross Value is less than or equal to 500 returns 100, if not 0


Logical Expressions

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 (&&)

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.

Syntax:

 <expression> && <expression>

Examples:

 IF(("Price" > 0) && ("Seller" == 'John Snow');450;0) - If Price is greater than 0 AND Seller is equal to John Snow, returns 450 if not returns 0
 IF(("City" != "#null") && ("Product" != 'Lasagna');1;0) - If City is non-null AND Product is different from Lasagna returns 1 if it does not return 0


Or Operator (||)

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 ||.

Syntax:

 <expression> || <expression>

Examples:

 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
 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 (!)

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 !.

Syntax:

 !<expression>

Example:

 IF(!BETWEEN("Delivery Date"; '01/01/2015'; '31/12/2015');2016;2015) - If the Delivery Date is NOT between 01/01/2015 and 12/31/2015 returns 2016. If between this period returns 2015


Auxiliary Functions

Basic helper functions are standard system functions and implement useful features for composing complex expressions.


ABS function

Function that returns the absolute numeric value of a base numeric value.

Syntax:

 ABS(<value operator or expression>)

Example:

 ABS("Price" / "Quantity") - Returns the absolute value of Price divided by Quantity


AVG function

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.

Syntax:

 AVG(<expression 1>; <expression 2>; ...)

Example:

 AVG("Taxes"; "Profit"; "Cost") - Returns the average between the sum of the Taxes, Profit and Cost columns


BETWEEN function

Checks whether a value is within the limits of the parameters used. Return true or false.

Syntax:

 BETWEEN(<expression to be tested>; <initial limit>; <end limit>)

Example:

 BETWEEN("Date Issued"; '01/01/2019'; '31/12/2019') - Returns true if Date Issued is between 01/01/2019 and 12/31/2019. Otherwise returns false

COUNT function

Returns number of occurrences (lines) for column or value.

By now this functions works only at Datasource expressions

Syntax:

 COUNT(<expression>) 

Example:

 COUNT("Product") - Returns number of occurrences (lines) of products

COUNT_DISTINCT function

Returns number of unique occurrences (lines) for column or value.

By now this functions works only at Datasource expressions

Syntax:

 COUNT_DISTINCT(<expression>) 

Example:

 COUNT_DISTINCT("Product") - Returns number of unique (different) occurrences (lines) of products

IF ELSE function (If .... Otherwise ...)

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.

Syntax:

  IF(<expression to be tested>; <expression if true>; <expression if false>)

Examples:

 IF(BETWEEN("Value";0;100);10;250) - If Value is between 0 and 100 returns 10, if not 250
 IF("Profit" == 0;0;"Profit" + "Taxes") - If Profit equals 0 returns 0, if it does not return the sum between Profit and Taxes
 IF("Product Code" == 3231;0;"Quantity" * 3;"Quantity") - If Product Code equals 3231 returns Quantity plus 3

LOG function

Returns the logarithm of a number on a defined basis. It can be used with only one parameter, in this case the "base 10" logarithm is used . If two parameters are used, the second server to inform the base to be used by the logarithm.

Syntax:

 LOG(<expression>;<base>)

Examples:

 LOG("Profit")- Returns the logarithm of the field Profit
 LOG("Price";2) - Returns the logarithm of the Price field in base 2


MAX function

Returns the largest value between two values.

Syntax:

  MAX(<expression 1>;<expression 2>)

Example:

 "Value" / MAX("Quantity";1) - Divides Value by the largest value between Quantity and 1


MIN function

Returns the smallest value between two values.

Syntax:

 MIN(<expression 1>; <expression 2>)

Example:

 "Value" / MIN("Cost"; 100) - Divides Value by the smallest value between Cost and 100


POWER function

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.

Syntax:

 POW(<expression>; <exponent>)

Examples:

 POW("Profit") - Returns the power of the Profit value.
 POW("Cost"; 3) - Returns the power of the Cost value, raised to 3


RANDOM function

Returns a random number within the range of values ​​passed as arguments.

Syntax:

 RANDOM(<start limit>; <end limit>)

Example:

 RANDOM(10;100) - Returns a random number between 10 and 100

ROUND function

Returns the rounded value of a value column or value.

Syntax:

 ROUND(<value>;<precision>) 

Example:

 ROUND("Profit") - If Profit 10.38 returns 10.00
 ROUND(15.65) - Returns 16.00
 ROUND(1.777;1) - Returns 1.8

SQRT function (Square Root)

Returns the square root of a value.

Syntax:

 SQRT(<value or expression>)

Examples:

 SQRT("Profit") - Returns the square root of the value Profit
 SQRT(81) - Returns the square root of 81


LIKE function

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.

Syntax:

 LIKE(< data>; <term>)

Example:

 LIKE("Product"; '%anh%') - Returns true if the Product contains the term anh or false otherwise

Date Functions

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:

  • 0: DATE_FIELD_YEAR (Part of the year)
  • 1: DATE_FIELD_MONTH (Month Part)
  • 2: DATE_FIELD_DAY (Daypart)
  • 3: DATE_FIELD_FORTNIGHT (Part of fortnight)
  • 5: DATE_FIELD_WEEK (Part of the Week)


DATE_PART function (Date Part)

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.

Syntax:

 DATE_ PART(<date>; <constant representing which part>)

Example:

 DATE_ PART("Issued Date"; 0) - Returns the year portion of the Issued Date


DAY_FROM_TODAY function (Days from today)

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.

Syntax:

 DAY_FROM_TODAY(<number of days>)

Example:

 DAY_FROM_TODAY(-1) - Returns yesterday's date


FIRST_DAY_OF function (First day of)

Returns the first day of a grouping. This function has two variations:

  • 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.

Syntax:

 FIRST_DAY_OF(<date part>; <base date>)

Examples:

 FIRST_DAY_OF(0;DAY_FROM_TODAY(0)) - Returns the first day of the year from today
 FIRST_DAY_OF(1;"Issue Date") - First Day of Month Based on Issue Date Column
  • 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.

Syntax:

 FIRST_DAY_OF(<date part>;<date modifier>;<date modifier value>)

Example:

 FIRST_DAY_OF(1;0;-1) - first day of current month of last year


LAST_DAY_OF function (Last day of)

Returns the last day of a date grouping. This function has two variations.

  • 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.

Syntax:

 LAST_DAY_OF(<date part>; <base date>)

Examples:

 LAST_DAY_OF(0;DAY_FROM_TODAY(0)) - Returns the last day of the year from today.
 LAST_DAY_OF(1;"Date Issued") - Last day of month based on Date Issued column
  • 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.

Syntax:

 LAST_DAY_OF(<date part>;<date modifier>;<date modifier value>)

Example:

 LAST_DAY_OF(1;0;-1) - last day of current month of last year


NEW_DATE function (New date)

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).

Syntax:

 NEW_DATE(<day>;<month>;<year>)

Example:

 NEW_DATE(1;4;DATE_PART("Issued Date";0)) - Creates the first April day of the year determined by the current row in the Issued Date column.


NUM_OF_DAYS function (Number of days)

Returns the number of days between two dates. Therefore you need two dates.

Syntax:

 NUM_OF_DAYS(<date 1>; <date 2>)

Examples:

 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.
 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)

Returns the number of months between two dates. Therefore, two date parameters are required.

Syntax:

 NUM_OF_MONTHS(<date 1>; <date 2>)

Example:

 NUM_OF_MONTHS(FIRST_DAY_OF(0; "Date"); "Date") - Returns the number of months between the first day of the year and the current month, based on the Date column.


PREVIOUS_DATE function (Previous date)

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.

Syntax:

 PREVIOUS_DATE(<day>; <month>)

Examples:

 PREVIOUS_DATE(15;12) - Considering that today's date is 14/11/2019, the last time December 15th occurred relative to today's date was 15/12/2018, so this will be the return.


Special Variables

They can be used in conjunction with expressions to create complex calculations. Must be used in double quotation marks (“)


  • "@count" - Total number of rows that were returned for the component.
  • "@row" - Current row number
  • "@sum[column]" - Sum of the indicated column.
    • Example: "@sum[Price]" - returns the sum of all rows in the Price column.
  • "@avg[column]" - Average column, similar to "@sum[column]" / "@count"
  • "@prev[column]" - Row value before current row for this column
  • "@totalRowValue[column]" - Value of total row, (if present), from this column.
  • "@accumCol[column]" - Cumulative value from column to current row. Useful for calculating variable mean.
    • Example: "@accumCol[column]" / "@row"