Logic

<< Click to Display Table of Contents >>

Current:  Create Calculated Field > Calculated Field Functions List 

Logic

Previous pageReturn to chapter overviewNext page

Functions

Syntax

Instructions

Examples

and

if <expr1> and <expr2> then <then> end

Performs a logical and conjunction on two expressions

For example:

if (col['product'] == "Coffee") and(col['market']=='West') then 1 else 2 end

case

case <expr> when <value1> then <return1> when <value2> then <return2> ... [else <else>] end

Perform a logic test and return the corresponding value. The case function evaluates expr, compares it to a series of values(value1, value2, and so on) and returns the result

For example:

case col ['Product Type'] when "coffee" then 1 when "tea" then 2 else 3 end

else

if <expr> then <then> [else <else>] end

Test a series of expressions while returning a <then> value for the first <expr> that is true

For example:

if (col ['sales']> "10000") then "High Profit" else "Loss" end

elseif

if <expr> then <then> [elseif <expr2> then <then2>...] [else <else>] end

Test a series of expressions, and return <then for the first <expr> that is true > Value

For example:

if(col['sales'] > 10000) then "high profit" elseif(col['sales'] < 10000 and col['sales'] > 1500) then "break even" else "loss" end

 end

if <expr> then <then> [elseif <expr2> then <then2>...] [else <else>] end

test a series of expressions while returning <then for the first <expr> that is true > value. must be placed at the end of the expression

For example:

if (col ['sales']> 10000) then "high profit" else if (col ['sales'] <10000 and col ['sales']> 1500) then " maintenance cost "else" loss "end

if

if <expr> then <then> [elseif <expr2> then <then2>...] [else <else>] end

Test a series of expressions, and return <then for the first <expr> that is true > Value

For example:

if (col['sales'] > 10000) then "high profit" else if (col['sales'] < 10000 AND col['sales'] > 1500) then "break even" else "loss" end

ifnull

ifnull(expr1, expr2)

If <expr1> is not null, return the expression, otherwise return <expr2>

For example:

ifnull(col['Profit'], 0)

iif

iif(expr,return1,return2)

Checks if a condition is met, returns a value if true, another value if false, or an optional third value or null if unknown

For example:

iif (col ['Sales']> 6,3,1), returns 3 if the value of this column is greater than 6, otherwise returns 1

isNull

isNull(expression)

Returns true if the expression does not contain valid data(null)

For example:

isNull(col['Profit'])=false

isNumber

isNumber(expression)

Checks whether the object is a numeric type. The numeric type returns true, otherwise it returns false

For example:

isNumber("work")=false

not

if not <expr> then <then> end

Perform a logical negation on an expression

For example:

if not (col['profit'] > 0) then "unprofitable" end

or

if <expr1> or <expr2> then <then1> end

Performs an or conditional evaluation on two expressions

For example:

if col ['Profit'] <0 or col ['Profit'] == 0 then "No profit" end

then

if <expre> then <then> [elseif ,expr2> then <then2>...] [else <else>] end

Test a series of expressions while returning <then for the first <expr> that is true > Value

For example:

if (col ['sales']> 10000) then "high profit" elseif (col ['sales'] <10000 and col ['sales']> 1500) then "break even "else" loss "end

when

case <expr> when <value1> then <return1> ... [else <else>] end

Find the first <value> that matches <expr> and return the corresponding <return>

For example:

case col['Procut_Name']

when 'Tea' then 1

when 'Coffee' then 2

else 3 end