Print Page | Close Window

Conditional Text

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=20711
Printed Date: 02 May 2024 at 11:28pm


Topic: Conditional Text
Posted By: Kitty1
Subject: Conditional Text
Date 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!



Replies:
Posted By: hilfy
Date 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

-------------
Proviti, Data & Analytics Practice
http://www.protiviti.com/US-en/data-management-advanced-analytics - www.protiviti.com/US-en/data-management-advanced-analytics


Posted By: lockwelle
Date 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


Posted By: Kitty1
Date 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 ?


Posted By: hilfy
Date 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

-------------
Proviti, Data & Analytics Practice
http://www.protiviti.com/US-en/data-management-advanced-analytics - www.protiviti.com/US-en/data-management-advanced-analytics



Print Page | Close Window