Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IIF function issue not going to else part

Status
Not open for further replies.

PD81

IS-IT--Management
May 14, 2010
12
GB
iif({Command.OLDSTATUS} in ["Cancel","CNCLACCT"], "CANCEL",
iif({Command.MATURESTATUS}="M","Mature",
iif({Command.SEC_TYP_CD} in ["OVND","TD"] and {Command.YESTERDAYTRADEID} <> 0,"ROLL",
"New")
)
)

I have this function which does take the 3rd contion if I comment 2nd line //iif({Command.MATURESTATUS}="M","Mature", - the other 2 condition works fine, any clue??

Thanks
Puneet


-cheers
Puneet
 
Puneet,

Your syntax is wrong for Crystal reports.

IF ... THEN ... ELSE

Will look something like:
Code:
IF {Command.OLDSTATUS} in ["Cancel","CNCLACCT"] THEN "Cancel" ELSE
IF ...

Hope this helps, cheers!

Mike
---------------------------------------------------------------
"To be alive is to revel in the moments, in the sunrise and the sunset, in the sudden and brief episodes of love and adventure,
in the hours of companionship. It is, most of all, to never be paralyzed by your fears of a future that no one can foretell."
 
Can mature status be null? I also don't think that the iif function works well with nulls in CR, so you could try changing it to:

if(
{Command.OLDSTATUS} in ["Cancel","CNCLACCT"] then
"CANCEL" else
(
if not isnull({Command.MATURESTATUS}) and
{Command.MATURESTATUS}="M" then
"Mature" else
(
if({Command.SEC_TYP_CD} in ["OVND","TD"] and {Command.YESTERDAYTRADEID} <> 0 then
"ROLL" else
"New"
)
)
)

Not sure I have the logic quite right...

-LB
 
Thanks Guys,
I started with IF...Else but somehow it was not going to the ELSE part.
Now i copied over LB's code but It seems to be not working says ) missing I put that but still.

@LB - yes the MatureStatus can be NULL, it will have value only when its is Mature.


-cheers
Puneet
 
if i am reading it right, lbass' formula appears to be missing a ) between '<> 0' and the final 'then'
 
Puneet,

If you removed all of the bracketting, what happens? I might be out in left field, but I am unsure it is needed - did you have a reason for all the parenthesis?

Another note, I have had issues with checking Nulls anywhere but the top of an IF Statement. If the order of your checks/conditions is non-heirarchical, perhaps changing the 1st and 2nd IF's around will make a difference?

Hope this helps!

Mike
---------------------------------------------------------------
"To be alive is to revel in the moments, in the sunrise and the sunset, in the sudden and brief episodes of love and adventure,
in the hours of companionship. It is, most of all, to never be paralyzed by your fears of a future that no one can foretell."
 
I do not have crystal in front of me, so cannot test this for errors, but i think if you rewrite your formula to check and accommodate for any nulls first, as MCuthill points out, that you will have better results.


IF {Command.OLDSTATUS} in ["Cancel","CNCLACCT"] then "CANCEL"
else
(IF isnull({Command.MATURESTATUS}) then "New"
else
(IF {Command.MATURESTATUS}="M" then "Mature"
else
(IF ({Command.SEC_TYP_CD} in ["OVND","TD"] and {Command.YESTERDAYTRADEID} <> 0 then "ROLL"
else
""
)
)
)
 
Sorry, try this:

if {Command.OLDSTATUS} in ["Cancel","CNCLACCT"] then
"CANCEL" else
(
if not isnull({Command.MATURESTATUS}) and
{Command.MATURESTATUS}="M" then
"Mature" else
(
if {Command.SEC_TYP_CD} in ["OVND","TD"] and
{Command.YESTERDAYTRADEID} <> 0 then
"ROLL" else
"New"
)
)

-LB
 
Thanks a ton.


-cheers
Puneet
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top