Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Technical Questions
Message Icon Topic: formula to eliminate year Post Reply Post New Topic
Author Message
kimt
Newbie
Newbie
Avatar

Joined: 06 Oct 2009
Online Status: Offline
Posts: 39
Quote kimt Replybullet Topic: formula to eliminate year
    Posted: 24 Mar 2015 at 11:21am
Have a report that lists columnar data by the year and quarter. Would like to eliminate the year if the quarter is > 1.

This is what I have but CR does not like it:

whileprintingrecords; if {Command.fldQuarter} > 1 then {Command.fldyear}= 0 else {Command.fldyear};

Essentially, if quarter > 1 then year = "" else year.

This works: whileprintingrecords; whileprintingrecords; if {Command.fldQuarter} > 1 then totext("") else totext({Command.fldyear},0,"")

Formatting came from yggdrasil on another CRbook forum.

Thanks.


Edited by kimt - 24 Mar 2015 at 3:24pm
IP IP Logged
paulhoving
Newbie
Newbie


Joined: 21 Nov 2014
Online Status: Offline
Posts: 7
Quote paulhoving Replybullet Posted: 25 Mar 2015 at 3:58am
I think this will do:

if {Command.fldQuarter} > 1 then 0 else {Command.fldyear};

Edited by paulhoving - 25 Mar 2015 at 4:03am
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 25 Mar 2015 at 4:34am
are you talking about suppressing the value in a row or changing a header?
your first formula would not work because you cannot set or alter values from your data set (" then {Command.fldyear}= 0").  The one you found that works does so because it is creating a 'new resulting field value' not trying to update your current field(s).
 
if you just wanted to hide the 'Year' field value in the row a simpler approach would be to conditionally suppress the field with  
{Command.fldQuarter} > 1
Or if you only have a 1:1 relationship of Q to a row and you sort from q1 to q4 I would recommend using the field format option of 'suppress if duplicated'. This would do the same thing but show the year value on the first row of a page if teh year was broken across pages.
 
 
IP IP Logged
kimt
Newbie
Newbie
Avatar

Joined: 06 Oct 2009
Online Status: Offline
Posts: 39
Quote kimt Replybullet Posted: 25 Mar 2015 at 6:15am
Thanks for the responses. After struggling for hours trying to write the correct formula with a little help on formatting, suppressing duplicate values took minutes. Guess that's how newbies learn.
IP IP Logged
Post Reply Post New Topic
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



This page was generated in 0.016 seconds.