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

Summary options in cross tab report 1

Status
Not open for further replies.

TechiUser

Programmer
Feb 20, 2006
7
GB
Hi,
I am new to Crystal reports and using Crystal XI. I need to create a cross tab report.

Can some one tell me if it is possible to create a custom formula for summarizing a field? What I need to get is a running product like

(X1+1)*(X2+1)*(X3+1)...

Thanks
 
Can you clarify whether X1, X2, X3 represent different instances of the same field versus separate fields?

-LB
 
Sorry, these are different instances of the same field.

I am looking at using log() and then exp() functions to get the result I want. But if you have a simpler solution, it would be great and your response is much appreciated.

Thanks
 
Not sure whether you have more than one column in your crosstab, and the solution is slightly different depending. We'll call your rowfield {table.row}, and we'll call the topmost instance of {table.row} in your crosstab "TopRowLabel", and your field containing X1,X2,X3, etc., {table.field}.

Insert a crosstab, add {table.row} as your row, and add {table.field} as your first summary. Create a formula:

whilereadingrecords;
0

Add this as a second summary to the crosstab. Then select the first summary, right click->format field->common->suppress->x+2 and enter:

whileprintingrecords;
numbervar k;
numbervar j := j + 1; //use this if there is only one column

if GridRowColumnValue("table.row") = 'TopRowLabel' then
//use the above line if more than one column else use the next commented out line:
//if j = 1 then
k := currentfieldvalue + 1 else
k := k * (currentfieldvalue + 1);
false //make this "true" if you don't want to display {table.field}

Then select the second summary field->right click->format field->common->display string->x+2 and enter:

whileprintingrecords;
numbervar k;
totext(k,0); //assuming you don't want decimals

Note that the use of the gridrowcolumnvalue line is necessary to reset the value of k per column. Otherwise the report could be more automated by using the counter j.

Note that this solution makes use of a solution provided by Ken Hamady in one of his newsletters re: using a running total in a crosstab.

-LB
 
Sorry, I had been pulled away from this for a while and could only look at this last week.

Thank you for the solution. Once I sorted-out how to use GridRowColumnValue("table.row") = 'TopRowLabel', it all worked great!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top