Using a string in IIF or CASE

Meeting place for R&R customers and clients to share tips and ideas. Post your questions, messages or problems here.
Post Reply
happydermis
Posts: 63
Joined: Tue Oct 10, 2017 12:44 pm

Using a string in IIF or CASE

Post by happydermis » Mon Nov 15, 2004 2:28 pm

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

Randall_Warden_(Guest)
Posts: 22
Joined: Tue Oct 10, 2017 12:44 pm

=> RE: Using a string in IIF or CASE

Post by Randall_Warden_(Guest) » Mon Nov 15, 2004 5:08 pm

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.__

happydermis
Posts: 63
Joined: Tue Oct 10, 2017 12:44 pm

==> RE: Using a string in IIF or CASE

Post by happydermis » Tue Nov 16, 2004 11:44 am

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

Randall_Warden_(Guest)
Posts: 22
Joined: Tue Oct 10, 2017 12:44 pm

===> RE: Using a string in IIF or CASE

Post by Randall_Warden_(Guest) » Tue Nov 16, 2004 5:00 pm

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.

happydermis
Posts: 63
Joined: Tue Oct 10, 2017 12:44 pm

====> RE: Using a string in IIF or CASE

Post by happydermis » Wed Nov 24, 2004 2:29 pm

Oh! Many thanks! It works____I am sorry it took me such a long time to answere...____Dekers

Post Reply