Thursday, November 1, 2012

Crystal Reports : Creating a Verbose value from a "Code"

In many instances, you'll be reporting from a series of Codes. Let's imagine that we are Grouping a report on {ORDERS.PRODUCTCODE}, which is a three character value denoting the type of Product sold.

Values are:

- WID (Widget 5000)
- SRV (Professional Services)
- MSC (Miscellaneous)

But now let's imagine the Boss wants to see the actual Type Names on the report (so, instead of WID he wants to see "Widget 5000".

This is easily done with a simple Formula:

1. From your Field Explorer, right click on "Formulas" and select New.

2. Give your new Formula a descriptive name like {@frmProductCode}.

3. Paste in the following text:

IF {ORDERS.PRODUCTCODE} = "WID" THEN "Widget 5000" ELSE
IF {ORDERS.PRODUCTCODE} = "SRV" THEN "Professional Services" ELSE
IF {ORDERS.PRODUCTCODE} = "MSC" THEN "Miscellaneous" ELSE "Unknown"

4. Now simply Save and Exit the Formula Editor, and place the new Formula on your report. Note the final ELSE kicks out "Unknown", so if someday someone mistakenly entered in "MSV" (fat fingering the "C") for Miscellaneous, we will get an "Unknown" on the report, making it way for us to determine what happened.

7 comments:

Patricia Pabustan said...

This is very beautiful for everyone. Thanks for share...........

Crystal Custom

Dhiman Sarkar said...

This are very nice. I am happy to read it...



Crystal Custom

jannati jahan said...

I love this blog. Thanks for share

Crystal Custom

jannati jahan said...

There's nothing like doing assignments and writing lots of code. C# is the most important emerging language.

http://www.dotnetobject.com/

amar jan said...

When you use a virtual table that was created as a Command, or when you use a Command from the Business Objects Enterprise Repository, Crystal Reports does not alter the syntax of the SQ L submitted to the server

Crystal Custom

Nomita Biswas said...

Crystals have the capacity to absorb, store, amplify, and transfer energy. The healing energy that is transferred by crystals merges into our own energy, lifting us with its high vibration.

Crystal Custom

Dharmendro Bhuyan said...

You'll want to research the latest styles in glasses so that your pick is appropriate for your audience.

Customized sunglasses