Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Report Design
Message Icon Topic: Conditional Text Post Reply Post New Topic
Author Message
Kitty1
Senior Member
Senior Member
Avatar

Joined: 14 Apr 2010
Online Status: Offline
Posts: 159
Quote Kitty1 Replybullet Topic: Conditional Text
    Posted: 06 May 2014 at 11:12am
Hi, I have a report which is grouped by Transaction Type, which is a 2 digit field in the G/L file. for example 05 stands for adjustment, 10 stands for invoice, etc. Is there a way that I can have text print out for each group level, explaining what the code means? I have no table to pull the descriptions from.   Thanks in advance for your help!
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3701
Quote hilfy Replybullet Posted: 06 May 2014 at 11:20am
You would have to write a formula to do this and, if any transaction types are added, you will have to update your report. Your formula might look something like this:[code]
Switch(
{MyTable.TransactionType}='05', 'Adjustment',
{MyTable.TransactionType}='10', 'Invoice',
...<and so on for all of your transaction types>...
True, 'Unknown Transaction Type - ' + {MyTable.TransactionType}
)

The last line will provide a default description if there is a transaction type that you haven't accounted for.

-Dell
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 06 May 2014 at 11:21am
SWITCH should work, but I never remember the syntax off the top of my head...something like
SWITCH({table.field},
"02", "what a 2 means",
"10", "what a 10 means")

or there is the if then way
if {table.field}="05" then "adjustment"
else if {table.field}="10" then "invoice"
//etc

HTH
IP IP Logged
Kitty1
Senior Member
Senior Member
Avatar

Joined: 14 Apr 2010
Online Status: Offline
Posts: 159
Quote Kitty1 Replybullet Posted: 07 May 2014 at 10:37am
Thank you. I am unfamiliar with Switch. Have never used it before. Is there an easy way to explain it ?
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3701
Quote hilfy Replybullet Posted: 08 May 2014 at 3:39am
Switch is similar to a "Case" statement in programming. Basically, it's like a big if..then..else if..then else if.. type statemtent. If you'll look at what Lockwelle and I both posted, we set it up so that it looks like "pairs" of statements separated by commas. The first part of each pair evaluates to true or false (the "if" part of the statement) and the second is the value you want to return if the first part is true (the "then" part of the statement. The final "True" in what I posted is like a "default" value that defines the result if none of the other statements are true.

-Dell
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.031 seconds.