Friday, February 24, 2012

Display text based on the value of a field

In my reports i have a field called mydataset.fruittype

In the details section when I display the data, currently the value is being displayed as 1, 2 etc...

I need to display for eg:

if the value of mydataset.fruittype = 1, then display apple,
if 2 then display mango etc...

How can i do that ? Do I need a formula editor for that.

I am using Crystal Reports 8.0

Can anyone please suggest me a solution.

Thanks.Create a formula @.fruits_name:

if {mydataset.fruittype} = 1 then 'Apple' else
if {mydataset.fruittype} = 2 then 'Mango' else
.
.
.
if {mydataset.fruittype} =n then 'xxxxxx'|||In the details section when I display the data, currently the value is being displayed as 1, 2 etc...

I need to display for eg:

if the value of mydataset.fruittype = 1, then display apple,
if 2 then display mango etc...

I think that you can create a view in your database set values you want to show it diretly in your report.


create view myview as
select
case when mydataset.fruittype=1 then
'apple'
case when mydataset.fruittype=2 then
'mango'
case when mydataset.fruittype=3 then
'orange'
end as fruit
from my table

using this, your client has less works to process the data and
server would make the work.

No comments:

Post a Comment