Formula operators
Formula operators allow you to apply if
/then
/else
conditions in your formulas.
You can leverage operators in your formulas to have them return true, false, or a predetermined value.
Formula operators
The operators include:
Operator | Description | Examples | ||
---|---|---|---|---|
|
Returns |
|
||
|
Conditional operator. Accepts multiple clauses. |
|
||
|
Returns the first value if it is not |
|
||
|
Takes a column name and a list of values. It checks each column value against the list of values in the formula, and returns |
|
||
|
Returns |
|
||
|
Returns |
|
||
|
Takes a column name and a list of values. It checks each column value against the list of values in the formula, and returns |
|
||
|
Returns |
|
Calculate the conditional sum
Calculating the conditional sum is useful when you want to see, for example, the total revenue for a product by region.
Conditional sum formulas follow this syntax: if (some condition) then (measure) else 0.
You can use this syntax to limit your search in cases when you don’t want to add a column filter.
For example: if ( product = shoes ) then revenue else 0
The following example shows you how to figure out the number of customers who bought both products, in this case an ipad and galaxy tablet. You can then find out the revenue generated by both products.
-
Create the following formula in the Formula Builder:
ipadcount = sum ( if ( product = 'ipad' ) then 1 else 0 ) > 0
This formula will provide you with the number of ipads that were bought.
-
You can then create another formula that looks like this:
galaxycount = sum ( if ( product = 'galaxy' then 1 else 0 ) > 0
And this formula will provide you with the number of galaxies that were bought.
-
Using nested formulas, you can combine these two formulas.
For example:
f1 = ipadcount + galaxycount
-
Now, you can search using the
f1
formula to find out the revenue generated by both products.
Related information
Operators in the Formula function reference ''' Related information