Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Crystal programming Post Reply Post New Topic
Author Message
rohanshweta
Newbie
Newbie


Joined: 07 Feb 2011
Online Status: Offline
Posts: 1
Quote rohanshweta Replybullet Topic: Crystal programming
     Posted: 07 Feb 2011 at 7:59am
What is wrong in this formula
 
IF {@year2 number} = 2013 And {@Current Month}='Jan' THEN '- 12' ELSE '- 13'
IF {@year2 number} = 2012 And {@Current Month}='Jan' THEN '- 11' ELSE '- 12'
IF {@year2 number} = 2011 And {@Current Month}='Jan' THEN '- 10' ELSE '- 11'
IF {@year2 number} = 2010 And {@Current Month}='Jan' THEN '- 09' ELSE '- 10'
IF {@year2 number} = 2009 And {@Current Month}='Jan'THEN '- 08' ELSE '- 09'
IF {@year2 number} = 2008 And {@Current Month}='Jan' THEN '- 07' ELSE '- 08'
IF {@year2 number} = 2007 And {@Current Month}='Jan' THEN '- 06' ELSE '- 07'
IF {@year2 number} = 2006 And {@Current Month}='Jan' THEN '- 05' ELSE '- 06'
IF {@year2 number} = 2005 And {@Current Month}='Jan' THEN '- 04' ELSE '- 05'
IF {@year2 number} = 2004 And {@Current Month}='Jan' THEN '- 03' ELSE '- 04'
IF {@year2 number} = 2003 And {@Current Month}='Jan' THEN '- 02' ELSE '- 03'
IF {@year2 number} = 2002 And {@Current Month}='Jan' THEN '- 01' ELSE '- 02'
IF {@year2 number} = 2001 And {@Current Month}='Jan' THEN '- 00' ELSE '- 01'
IF {@year2 number} = 2000  And {@Current Month}='Jan'THEN '- 99' ELSE '- 00'
IF {@year2 number}= 1999 And {@Current Month}='Jan' THEN '- 98' ELSE '- 99'
IF {@year2 number} = 1998 And {@Current Month}='Jan' THEN '- 97' ELSE '- 98'
IP IP Logged
c16271
Groupie
Groupie
Avatar

Joined: 24 Aug 2010
Location: United States
Online Status: Offline
Posts: 48
Quote c16271 Replybullet Posted: 07 Feb 2011 at 10:23am
What's it suppose to do?

Why not follow the If - Else if - Else?

Also, couldn't you do this a bit more dynamic? I could think of a couple of ways to do this...



IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 08 Feb 2011 at 3:42am
I am assuming that you always get - 98...because it is the last if statement, always, irregardless of what the field value is.  I would think you would want to do as c16271 suggests
if x = 2013 and y = 'jan'  then 12 ...stop, the else is always
or
if x = 2013 and y = 'jan'  then 12 ...stop, the else is always
if x = 2013 and y <> 'jan' then 13  ...i think this is what you are after
 
or
if y = 'jan' then
  '-' + right(totext(x -1, "", 0), 2)
else
  '-' + right(totext(x, "",0), 2)
 
which would be much more dynamic, again, as c16271 suggests.
 
HTH
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum