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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Array for Group Names

Status
Not open for further replies.

shelby55

Technical User
Jun 27, 2003
1,229
CA
Hello

I am using Crystal 9.0 and I've never created an array before.

The report has 3 groups: catchment_area, hospital region and hospital. I want to create a summary statement in the report footer indicating what % of a certain region is treating a certain catchment area.

To start, I'm just trying to get at volumes per catchment area of which there are 2: Primary and Secondary. Using the formula below it results in 0 but if I query for Secondary Catchment Area it shows the correct amount, I believe because Secondary is the last group. So maybe this needs looping (which I don't know how to do):

Code:
 whileprintingrecords;
numbervar primcatch_ttl:=0;
stringvar array catch;
redim catch[2];
catch[1]:="Primary Catchment Area";
catch[2]:="Secondary Catchment Area";

if {@Catchment}=catch[1] then primcatch_ttl:=Sum ({DAD.# Dschg}, {@Catchment});
totext(primcatch_ttl,0);

Any and all assistance greatly appreciated. Thanks.
 
Take a look at Crosstab, you'll find it under Insert

[yinyang] Madawc Williams (East Anglia, UK). Using Crystal 2008 with SQL and Windows XP [yinyang]
 
Hi

I know how to create a crosstab but I want to create a text box that indicates what % a certain hospital is serving a specific catchment area so I need to know how to get at the specifics. I assumed it was an array I needed to do this.

Thanks.
 
Hi Shelby,

Can you provide more guidance as to your report structure? I have read your post a few times, and I am not 100% of what you are looking to acheive. I get the impression it is a pair of conditional sums divided by some form of total. *IF* I have understood your inquiry correctly you will need fields such as follows, though you may have to make some adaptations based on your specific report layout. "Resets" (generally) go at the start of a Group or Report (in the header), "Accum"s (generally) in the details (or inner group) and "Displays" (genereally) at the end of a Group or Report (fotoer).

Using these assumptions, please try the following:
{@Reset_PrimaryCatchmentTotal}
Code:
[blue]WhilePrintingRecords[/blue];
[blue]Shared NumberVar[/blue] PrimaryCatchmentTotal:=0;

{@Reset_SecondaryCatchmentTotal}
Code:
[blue]WhilePrintingRecords[/blue];
[blue]Shared NumberVar[/blue] SecondaryCatchmentTotal:=0;
*Note: the above can perhaps be merged into one resest, I always keep separate

{@Accum_CatchmentTotals}
Code:
[blue]WhilePrintingRecords[/blue];
[blue]Shared NumberVar[/blue] PrimaryCatchmentTotal;
[blue]Shared NumberVar[/blue] SecondaryCatchmentTotal;

[blue]IF[/blue] {@Catchment} = "Primary Catchment Area"  [blue]THEN[/blue] PrimaryCatchmentTotal:=PrimaryCatchmentTotal+1 [blue]ELSE[/blue]
[blue]IF[/blue] {@Catchment} = "Secondary Catchment Area"  [blue]THEN[/blue] SecondaryCatchmentTotal:=PrimaryCatchmentTotal+1 [blue]ELSE[/blue] 0;

The part I am unsure of is what you are measuring these against, a total count perhaps? Assuming this, your final displays would look something like follows:

{@Display_PrimaryCatchmentTotal}
Code:
[blue]WhilePrintingRecords[/blue];
[blue]Shared NumberVar[/blue] PrimaryCatchmentTotal;

PrimaryCatchmentTotal /  [blue]Count[/blue]({TransactionID})

{@Display_SecondaryCatchmentTotal}
Code:
[blue]WhilePrintingRecords[/blue];
[blue]Shared NumberVar[/blue] SecondaryCatchmentTotal;

SecondaryCatchmentTotal /  [blue]Count[/blue]({TransactionID})
*Note: The last line of the "Display" formula's will need to be adjusted to fit your formatting requirements.

Hope this helps, as there are many assumptions in this solution, please advise if not what you were seeking for a solution.

Cheers!

Mike
---------------------------------------------------------------
"To be alive is to revel in the moments, in the sunrise and the sunset, in the sudden and brief episodes of love and adventure,
in the hours of companionship. It is, most of all, to never be paralyzed by your fears of a future that no one can foretell."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top