...
Code Block |
---|
|
/* Get the discount rate that should apply to
the calls that match the filter conditions */
$discountRate = discount.rate,
// Now apply the discount
$value = $value * ( 1 - $discountRate)
... |
Code Block |
---|
|
if(_out.AppleHarvestDate < _toDate('20210101'), 1,
/* Evaluates to 1 if AppleHarvest Date is Before 1st January 2021*/
0if( _out.AppleHarvestDate < _toDate('20210101'), 1,
//* andelse, to 0 if it is not
*/
0
) |
Layout for if()
Simple
For simple if() statements we recommend the following style of layout:
...
Code Block |
---|
switch(
[ condition expression 1, Statement 1 ],
[ condition expression 2, Statement 2 ],
// default
_NULL
)
// example
switch(
[ $foo > 100, $x = "HIGH" ],
[ $bar > 50, $x = "MEDIUM" ],
// default
$x = "LOW",
) |
...
Code Block |
---|
switch (
// description of what the statement is doing
[ $foo == 100,
$x = "HIGH"
],
// description of what the statement is doing
[ $bar == 50,
do (
$x = "Medium",
$x = toUpper($x)
)
]
// default
do (
$x = "LOW"
)
) |
...