Using a string in IIF or CASE
-
- Posts: 63
- Joined: Tue Oct 10, 2017 12:44 pm
Using a string in IIF or CASE
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
-
- Posts: 22
- Joined: Tue Oct 10, 2017 12:44 pm
=> RE: Using a string in IIF or CASE
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.__
-
- Posts: 63
- Joined: Tue Oct 10, 2017 12:44 pm
==> RE: Using a string in IIF or CASE
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
-
- Posts: 22
- Joined: Tue Oct 10, 2017 12:44 pm
===> RE: Using a string in IIF or CASE
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.
-
- Posts: 63
- Joined: Tue Oct 10, 2017 12:44 pm
====> RE: Using a string in IIF or CASE
Oh! Many thanks! It works____I am sorry it took me such a long time to answere...____Dekers