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

Need Cumulative total along with the regular total in Cross-tab 1

Status
Not open for further replies.

shabad

Programmer
Nov 20, 2008
1
US
Hi,

I am using crytal 11 and i need to have cumulative totals along with the regular total which i need help as i am new to crystal reports.

right now my cross-tab looks like this

Rec Rel Total Cumulative
9/01/2008 (113) 11 (102)
9/5/2008 (239) 113 (126) 228
(161) 159 (2) 230
----------------------------------
Total --- -- ---
----------------------------------

I did not calculate the row total here in this example.

Can someone plz help me on this, its a bit urgent.

Thanks
shabad

 
I don't think a crosstab will do that. Unless someone else can find a clever answer, you'll need to do a lot more work and get the result with a 'mock-crosstab'.

A 'Mock Crosstab' is something that looks like a Crosstab, but in fact you define each column yourself, normally as a running total. This would need to go in the report footer, because running totals count as the reports 'run' and they will not be complete until then. Crystal should have included an example along with the Crosstabs.

You can save a little time by doing a paste to a dummy report, changing the name and then pasting back.

Each running total will count the record if it was within the criteria. Have another running total that is not reset for your cumulative total.

[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
You could do this within the crosstab by adding a second summary field (it could be the original one entered a second time) to use as a holder field for the running total. Go to teh customize style tab->summarized fields->horizontal->show labels.

In preview mode, suppress the inner columns, column total, and label for the second summary, and resize the column width to minimize.

Then select the first summary in the total column->right click->format field->suppress->x+2 and enter:

whileprintingrecords;
numbervar cumul := cumul + currentfieldvalue;
false

Then select the second summary field->right click->format field->display string->x+2 and enter:
whileprintingrecords;
numbervar cumul;
totext(cumul,0,"")

A manual crosstab might be as simple or simpler, if you don't have that many columns.

-LB
 
Hi LB,

It is working fine!!!

Do you know how to do the same trics, but for "rows" instead of column ordering?

Thanks

Pier
 
For horizontal running totals, you have to hard code the row values, so let's say you have a crosstab with {Orders.Ship Via} as the row. You would then set up your running totals like this:

whileprintingrecords;
stringvar ups;
stringvar loomis;
if gridrowcolumnvalue("Orders.Ship Via") = "UPS" then
ups := ups + currentfieldvalue;
if gridrowcolumnvalue("Orders.Ship Via") = "Loomis" then
loomis := loomis + currentfieldvalue;
//etc.

Otherwise, you could consider pivoting the crosstab--if you need the cumulative totals in one direction only.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top