Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Report Design
Message Icon Topic: Subtotal from a Running Total Post Reply Post New Topic
Author Message
jsh8286
Groupie
Groupie
Avatar

Joined: 09 Mar 2012
Online Status: Offline
Posts: 46
Quote jsh8286 Replybullet Topic: Subtotal from a Running Total
    Posted: 29 Jan 2019 at 2:10pm
Have a report that does not have any groupings. Only a detail section. I am trying to use a running total to calculate a subtotal all within the detail section.The reason is we need multiple subtotals but all within the detail section of the report.

So here is an example of the items listed on the report:

Item A               100.00
Item B               100.00
Item C               100.00
SUBTOTAL             300.00

Item D               200.00
Item E               100.00
SUBTOTAL             300.00

We want the running total to add the items and put the running total amount where you see above. We have done this but we also need to reset the running total when it encounters a SUBTOTAL.

So in the example above if I were to put our running total beside the amounts also with the knowledge the running total needs to be reset when it encounters a subtotal here is what we get:

Item A               100.00        100.00
Item B               100.00        200.00
Item C               100.00        300.00
SUBTOTAL               0.00

Item D               200.00        200.00
Item E               100.00        300.00
SUBTOTAL               0.00     

So as you can see the SUBTOTAL is at 0.00 since we need to reset it. All we need is for the last running total from the line above to pass down to the subtotal line and we are good.

Any suggestions or postings would be greatly appreciated.
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 30 Jan 2019 at 4:58am
I have never tried sub-totaling without a group of some sorts.  There maybe a way to do it with a manual running total.  I would have to think about this awhile to see if I could come up with a solution.
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 30 Jan 2019 at 5:21am
First create a formula something like this.

shared numbervar subtotal;
if {Sheet1_.Item } = 'SUBTOTAL' THEN
    subtotal
    else if previous({Sheet1_.Item })  = 'SUBTOTAL' then
        subtotal := {Sheet1_.amount}
    else    subtotal := subtotal +{Sheet1_.amount};

then create a second detail line that will have the item column and formula column in it.  The first detail row will be suppressed if the item is equal to SUBTOTAL, the second detail row will be suppressed if the item is not equal to SUBTOTAL.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 30 Jan 2019 at 8:18am
I would also suggest that you already had to create logic to decide when to 'insert' the subtotal which I assume is on a details B section.
That same logic can be applied to the RT for when to reset (using a formula).
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.016 seconds.