Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

loop and formula crystal 8.5

Status
Not open for further replies.

Swetal2004

Technical User
Mar 5, 2004
30
US
pt_id dept_cd Flag
110 444
110 441
110 442
110 443
111 389 Yes
111 310 Yes
111 311 Yes
111 312 Yes
112 289 Yes
112 210 Yes
112 246 Yes
112 267 Yes
113 489 Yes
113 411 Yes
113 491 Yes
113 490 Yes

In my database there are two columns as shown above. If the pt_id falls in one of (389, 289,489)dept_cd then I want flag (as shown above it the third column) each occurrence of that particular pt_id using a Crystal 8.5 formula or looping structure. Can someone help me? Thanks.
 
Group on {table.patientID}. Then create a formula {@thosedept_cds}:

if {table.dept_cd} in [389, 289,489] then 1

Then create a second formula:

if sum({@thosedept_cds},{table.patientID}) > 0 then "Yes"

Place this formula in the detail section.

-LB

 
Thanks;
Problem is I have to do it without using groups. I have to use a formula to solve it.
 
The groups do not have to be displayed. You can suppress the group header and footer. If you still feel you cannot insert a group, can you explain why?

-LB
 
pt_id dept_cd Flag
110 444
110 441
110 442
110 443
111 389 Yes
111 310 Yes
111 311 Yes
111 312 Yes
112 289 Yes
112 210 Yes
112 246 Yes
112 267 Yes
113 489 Yes
113 411 Yes
113 491 Yes
113 490 Yes
Once I flag each occurence of pt_ids that has one of (389, 489, 289) dept_cd then only I can group them because it's the requirement.
 
Please explain why you cannot insert a group on patient ID and then suppress the group header and footer. Are you saying you then need to group the IDs by the Flag field? What is the goal of your report here? What do you want the final report to look like?

-LB
 
I am connecting this table to another table and query on other field after I get unique pt_ids
 
To show only those patient IDs, you don't need a detail level flag. You can just go to edit selection formula->GROUP and enter:

sum({@thosedept_cds},{table.patientID}) > 0

You can then suppress the detail section.

If you add fields from other tables or add a subreport to the groups, they will only appear for the groups displayed by the group selection. I would use a left join to another table to ensure that the above IDs will appear in the report.

-LB
 
I have to group my data on another field. So specifically don't want pt_id as a group.
I was thinking of a loop structure if possible.
 
Hi,
You could try ( assuming you have now revealed all your requirements) a running total ( see the docs on this as I have not used them, so I cannot be specifc as to use or placement restrictions)
using the formula for
identifying the relevant ones:
if {table.dept_cd} in [389, 289,489] then increment the running total variable..

Place the variable in the report.

[profile]
 
I have to group my data on another field.
You can have several levels of group. Please follow lbass's advice, which will solve your problem.

[yinyang] Madawc Williams (East Anglia, UK) [yinyang]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top