Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Formula Writing - Tricky one Post Reply Post New Topic
Author Message
Kilantro
Newbie
Newbie


Joined: 15 May 2011
Online Status: Offline
Posts: 3
Quote Kilantro Replybullet Topic: Formula Writing - Tricky one
     Posted: 15 May 2011 at 3:35pm
Hi,
 
I am using Crystal 11
 
Would really appreciate any input that anyone would have on the following issue - its doing my head in...
Cry
 
I have 4 seperate fields (representing type of medical tests)
 
UDF2.Test1
UDF2.Test2
UDF2.Test3
UDF2.Test4
 
all with data values 1,2,3,4,5 (representing the test result)
 
I need them displayed in a report so that the 4 fields are displayed in 1 field (Tests Done), and then the lookups (Test Result) are used to display in another field.
Eg.
 
Patient ID      Test Done        Test Result
123                  Test 1              2
123                  Test 4              1
456                  Test 1              4
789                  Test 2              1
789                  Test 3              1
 
I can't get the the 2 summary fields (Test Done and Test results) to come out how I want them!
 
 
Thanks,
K
 
IP IP Logged
Keikoku
Senior Member
Senior Member


Joined: 01 Dec 2010
Online Status: Offline
Posts: 386
Quote Keikoku Replybullet Posted: 16 May 2011 at 3:11am
Since all of the data is on the same record, and you want to display each test result in a separate row, you will need to use a formula.

Your formula will involve checking each field to see if there is a value, and then building a string as you go.

You will use chr(10) to specify that the next test should appear on a new line.

ie:


local stringvar temp = "";

if table.test1 then
   temp := temp + {patient ID} + (tab character) + "test1" + (tab character) + totext(table.test1)

if table.test2 then
   temp := temp + chr(10) + {patient ID} + (tab character) + "test2" + ...

...

temp;


This formula will take each record and output a formatted version. You can then manually place your headings to line up with each "column". You may consider using more than one tab character between each column.

Edited by Keikoku - 16 May 2011 at 3:13am
IP IP Logged
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