Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Published by Scroll Versions from space DEV and version next

...

For example, the following replaces values in the same column with IN if they are greater than 0.5 or OUT otherwise:

D code

set col: testCol value:IF($col >= 0.5, 'IN','OUT')

In the above, the token $col is a reference back to the value defined for the column (testCol in this case).  However, you can replace it with a reference to any column in the dataset. 

...

You can change together IF functions in the following manner:

 

D code

set col: testCol value:IF($col >= 0.5, 'IN',(IF($col >= 0.35, 'MAYBE IN','OUT')))

However, these can become problematic to debug. Instead, you can use the CASE function to assist in building more complex logical trees. The following is more legible and easier to manage:

 

D code

set col:testCol value:CASE([ $col >= 0.75, 'IN', $col >= 0.35, 'MAYBE IN', 'OUT'])

If testTestOutput if true
If:$col >= 0.75IN
If above is false:$col >= 0.35
MAYBE IN
If above is false:defaultOUT

For more information, see CASE Function.

...

In the above example, suppose you have a second column called, Paid, which contains Boolean values. You could expand the previous statement to include a test to see if Paid=true:

D code

set col:testCol value:CASE([ ($col >= 0.75 && Paid == true), 'IN', ($col >= 0.35 && Paid == true), 'MAYBE IN', 'OUT'])

The above performs a logical AND operation on the two expressions in each tested case. The logical operator is &&.

You can also reference explicit functions to perform logical tests. The above might be replaced with the following:

D code

set col:testCol value:CASE([ AND($col >= 0.75, Paid == true), 'IN', AND($col >= 0.35, Paid == true), 'MAYBE IN', 'OUT'])

LogicLogical OperatorLogical Function
Logical AND(exp1 && exp2)AND(exp1,exp2)
Logical OR(exp1 || exp2)OR(exp1,exp2)
Logical NOT!(exp1 == exp2)NOT(exp1,exp2)

...