Conditional Statements
Conditional statements are formulas that enable you to create additional categories in your data set. When the condition is met; the new category is added to your visualization without modifying the data source itself.
For example; if you want to calculate only certain values according to conditions you define; you can use a conditional statement to include only the values of interest.
Insights provides several conditional statements that enable you to evaluate criteria and display only the relevant results in your dashboard.
IF
IF (Boolean_expression; true value; false value)
Evaluates a boolean expression and returns the first value when evaluated as true; and returns the second value when evaluated as false.
For example:
(if(Sum(Sales) <10; 0;="0;" sum(sales)="Sum(Sales)" )=")"></10;>
Nested IF statements are also supported.
For example:
if (Sum(Sales) <100 1="1" ;=";" ;(if=";(if" (sum(sales)="(Sum(Sales)"><1000 ;=";" 2;="2;" 3)="3)" )=")"></1000></100>
isNull
ISNULL ()
Returns true if the expression doesn't contain data (Null). Can be used as a condition when writing conditional statements.
For example:
If (ISNULL(sum(deals)); 0; sum(deals) )
Case
CASE
WHEN Boolean_expression THEN result_expression
[ ... ]
[ ELSE else_result_expression ]
END
The CASE function evaluates boolean expressions; and when evaluated as true; returns the corresponding result_expression. If no match is found; the else_result_expression is returned. If there is no default returned and no values match; then Null is returned.
For example:
CASE
WHEN Sum(Sales) <100 1="1" then="THEN"></100>
WHEN Sum(Sales) <1000 2="2" then="THEN"></1000>
ELSE 3
END