Formula operators allow you to apply
else conditions in your
formulas. You can leverage operators in your formulas to have them return true,
false, or a predetermined value. The operators include:
||Returns true when both conditions are true, otherwise returns false.||
Note: Not available for row level security (RLS) formulas.
||Returns the first value if it is not null, otherwise returns the second.||
||Returns true if the value is null.||
||Returns true if the condition is false, otherwise returns false.||
||Returns true when either condition is true, otherwise returns false.||
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
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 galaxys that were bought.
Using nested formulas, you can combine these two formulas.
f1 = ipadcount + galaxycount
Now, you can search using the
f1formula to find out the revenue generated by both products.