# 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

`and`

Returns `true` when both conditions are `true`, otherwise returns `false`.

`(1 = 1) and (3 > 2) = true`
`lastname = 'smith' and state ='texas'`

 Not available for row-level security (RLS) formulas.

`if…​then…​else`

Conditional operator. Accepts multiple clauses

`if ( item type in {'shirts', 'jackets', 'sweatshirts', 'sweaters'}) then 'tops' else if ( item type in {'shorts', 'pants'}) then 'bottoms' else 'all other apparel'`
`if (cost > 500) then 'flag' else 'approve'`

`ifnull`

Returns the first value if it is not `null`, otherwise returns the second value.

`ifnull (cost, 'unknown')`

`in`

Takes a column name and a list of values. It checks each column value against the list of values in the formula, and returns `true` if the column value matches one of the values in the formula.

`state in { 'texas' , 'california' }`

`isnull`

Returns `true` if the value is `null`.

`isnull (phone)`

`not`

Returns `true` if the condition is `false`, otherwise returns `false`.

`not (3 > 2) = false`
`not (state = 'texas')`

`or`

Returns `true` when either condition is `true`, otherwise returns `false`.

`(1 = 5) or (3 > 2) = true`
`state = 'california' or state ='oregon'`

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

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

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

3. Using nested formulas, you can combine these two formulas.

For example: `f1 = ipadcount + galaxycount`

4. Now, you can search using the `f1` formula to find out the revenue generated by both products.