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

Summaries in Header

Status
Not open for further replies.

Samantha44

Technical User
May 11, 2005
3
GB
Please can anyone help, I'm trying to write a report using Crystal 11. I need two date fields in a report which are contained in the same table, within the same field in two seperate rows eg

Type 1 12/05/05
Type 1 30/05/05
Type 2 10/04/05
Type 2 30/04/05

Basically from the above I have to pull the latest date for both types and show them in one line.

Eg XXXX XXXXXX XXXXX Type 1 30/05/05 Type 2 30/04/05 XXXXX XXXX

there is other data being pulled into the line from other tables.

I have tried using grouping but that just gives me the max of both types.

Is there any way of using a formula/calc field?

Any help would be much appreciated.

thanks

Sam.
 
Group by the Type

Create 2 formulas for display purposes in the group footer of the type grouping (you can suppress the detail section):

maximum({table.date1},{table.Type})

maximum({table.date2},{table.Type})

If you want to limit rows to some range of dates, as in using a parameter so as not to pull everything from the database, adjust the Report->Selection Formulas->Record to something like:

(
{table1.date1} >= {?Datestartparameter}
and
{table1.date1} <= {?Endstartparameter}
)
or
(
{table1.date2} >= {?Datestartparameter}
and
{table1.date2} <= {?Endstartparameter}
)

-k
 
thanks for the reply, that's as far as i got, but i need to put the results of those formulas into the group above so that they appear all on same line as other data. thus reporting in a flat grid.


But thanks anyway

i'll just keep looking

sam
 
I'm guessing that you want the maximum dates per type for some outer group (let's call it {table.client}). Then you should group on type, and then create three formulas:

//{@reset} to be placed in the client group header:
whileprintingrecords;
stringvar output;
if not inrepeatedgroupheader then
output := 0;

//{@accum} to be placed in the group footer for type:
whileprintingrecords;
stringvar output;
output := output + {table.type}+" " +
totext(maximum({table.date},{table.type}),"dd/MM/yy")+" ";

//{@display} to be placed in the client group footer:
whileprintingrecords;
stringvar output;

You can then suppress the type group header and footer and the detail section.

-LB
 
If a solution doesn't work, you'll probably discover it's the result of not posting technical information, note that successful posts include:

Crystal version
Database/connectivity used
Example data
Expected output

I guess I understand more fully now, althouh you didn't state what this outer grouping is. You ALWAYS have 2 dates in a row which you need the MAX of.

This should get you close even if my assumed ALWAYS isn't the case:

In the details create a formula such as:

whileprintingrecords;
datevar Type2;
datevar Type1;
if remainder(recordnumber,4) = 0 then
Type2:=maximum({table.date},Previous({table.date})
else
if remainder(recordnumber,2) = 0 then
Type1:=maximum({table.date},Previous({table.date})

Now you have both dates saved, so in the suppress for the details section place the following:

not(remainder(recordnumber,4) = 0)

Now for display purposes use:

// first date
whileprintingrecords;
datevar Type1;

// second date
whileprintingrecords;
datevar Type2

Hopefully this will get you closer.

If not, you may need to check that the previous({table.type}) = {table.type}) as a qualifier and then base it on this rather than recordnumbers.

-k

-k
 
Thank you very much
you're a star

thats worked perfectly

sam


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top