Page 1 of 1
Using a string in IIF or CASE
Posted: Mon Nov 15, 2004 2:28 pm
by happydermis
Hey all,____I^m rather new to R&R so I hope this is not a silly question.____I would like to have the following instruction:__IIF(self_price<>0,BILL1-BILL2,^error^)____Problem: R&R will not let me use ^error^ as my else-expression. If I use numbers it is all fine but strings are not allowed. There are examples in the HELP that show exactly such use. Why doesn^t it work for me :-(____Many thanks, Dekers
=> RE: Using a string in IIF or CASE
Posted: Mon Nov 15, 2004 5:08 pm
by Randall_Warden_(Guest)
From R&R Help:____"IIF(condition,true-value,false-value) where condition can be any data type. The values returned, true-value and false-value, must be the same data type, but need not be the same data type as condition."____One option is to change your IIF statement from____ IIF(self_price<>0,BILL1-BILL2,^error^)____to____ IIF(self_price<>0,str(BILL1-BILL2,,2),^error^)____so that the difference is formatted with 2 decimal places.__
==> RE: Using a string in IIF or CASE
Posted: Tue Nov 16, 2004 11:44 am
by happydermis
Oh! Thank you very much for the tip. (It really do works ;-) )____I was tring this one with a CASE condition but with no success maybe someone would have an idea?____CASE(str(CONTRACT->UNITPRICE,,2),__str((P1_PRICE,P1_AMOUNT),,2),__str((P2_PRICE,P2_AMOUNT),,2),__str((P3_PRICE,P3_AMOUNT),,2),__str((P4_PRICE,P4_AMOUNT),,2),__str((P5_PRICE,P5_AMOUNT),,2),__str((P6_PRICE,P6_AMOUNT),,2),__str((P7_PRICE,P7_AMOUNT),,2),__str((P8_PRICE,P8_AMOUNT),,2),__str((P9_PRICE,P9_AMOUNT),,2),^ERR^)____I was simply trying to get ERR every time when UNITPRICE didn^t match any of the other prices but every time I get a syntax error...____I am greatful for any answer, thanks!__Dekers
===> RE: Using a string in IIF or CASE
Posted: Tue Nov 16, 2004 5:00 pm
by Randall_Warden_(Guest)
Try this:____CASE(str(CONTRACT->UNITPRICE,,2),__str((P1_PRICE,P1_AMOUNT),,2),"",__str((P2_PRICE,P2_AMOUNT),,2),"",__str((P3_PRICE,P3_AMOUNT),,2),"",__str((P4_PRICE,P4_AMOUNT),,2),"",__str((P5_PRICE,P5_AMOUNT),,2),"",__str((P6_PRICE,P6_AMOUNT),,2),"",__str((P7_PRICE,P7_AMOUNT),,2),"",__str((P8_PRICE,P8_AMOUNT),,2),"",__str((P9_PRICE,P9_AMOUNT),,2),"",^ERR^)____You were leaving out the result of each comparision.
====> RE: Using a string in IIF or CASE
Posted: Wed Nov 24, 2004 2:29 pm
by happydermis
Oh! Many thanks! It works____I am sorry it took me such a long time to answere...____Dekers