Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Running totals sum in Report Footer Post Reply Post New Topic
Page  of 2 Next >>
Author Message
achandana01
Groupie
Groupie
Avatar

Joined: 20 Jul 2011
Online Status: Offline
Posts: 59
Quote achandana01 Replybullet Topic: Running totals sum in Report Footer
    Posted: 21 Nov 2011 at 1:47pm
Hello All,
 
I do have a table like this
 
Department Customer ID Purchase ID City
Laptops A123 101 Los Angeles
Laptops A123 101 Los Angeles
Tablets A123 101 Los Angeles
Laptops B123 102 Los Angeles
Laptops A123 102 Dallas
Smart Phones A123 101 Los Angeles
Smart Phones B123 105 New York
Laptops A123 107 New York
Tablets A123 108 Dallas
 
I need a summary like this way
 
  Los Angeles New York Dallas Totals
Laptops 2 1 1 4
Smart Phones 1 1 0 2
Tablets 1 0 1 1
Report Footer 4 2 2 8
 
Let see the scenerio
 
1) For Losangeles A customer named A123 bought two laptops with same Purchase ID and the same customer bought laptop in NY & Dallas with different PID's
2) For Los Angeles B123 bought another laptop with purchase ID 102
 
I grouped it by department and I am using Running totals to count the number at group footer
 
Field to Summarize -- > Department
Type of Summart --> Distinct Count
Evaluate : choose formula and I put city = "Los Angeles "
Reset : On change of group : Department
 
I am getting the correct number at group level but to get the totals at the report footer I have no clue how to write a formula/running totals for it.
 
To be precise all I need is just to sum all numbers at the group level to get a total at report footer.
 
Please give me suggestions on it,any help will be appreciated greatly.
 
 


Edited by achandana01 - 22 Nov 2011 at 5:48am
chand
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 22 Nov 2011 at 3:19am
as people have been pointing out lately, try a cross-tabs for the summary.  It should be exactly what you are looking for, and they're pretty easy to set up.
 
HTH
IP IP Logged
achandana01
Groupie
Groupie
Avatar

Joined: 20 Jul 2011
Online Status: Offline
Posts: 59
Quote achandana01 Replybullet Posted: 22 Nov 2011 at 5:53am
Thank you for you suggestion, I tried it but I am still not getting the exact result at report footer which leaves me at the same  page where I am when I tried running totals hoever I learned somethign new today and thanks for that :).
 
I am getting something like this :
  Los Angeles New York Dallas Totals
Laptops 2 1 1 4
Smart Phones 1 1 0 2
Tablets 1 0 1 2
Report Footer 3 2 2 7
 
but I need like the following :
 
  Los Angeles New York Dallas Totals
Laptops 2 1 1 4
Smart Phones 1 1 0 2
Tablets 1 0 1 2
Report Footer 2 2 2 6
 
Because I am using distinct count I am not getting exact totals in the report footer
 
Could you please look into this one more time ?


Edited by achandana01 - 22 Nov 2011 at 6:03am
chand
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 22 Nov 2011 at 8:06am
but the totals running vertically don't match?  what's that rule
IP IP Logged
achandana01
Groupie
Groupie
Avatar

Joined: 20 Jul 2011
Online Status: Offline
Posts: 59
Quote achandana01 Replybullet Posted: 22 Nov 2011 at 8:11am
Nope they don't match.
 
The rule is to do a distinct count on purchase ID by department wise and
 
For report footer I need the sum of all the values at the group level not by distinct count of all purchase ID's
chand
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 23 Nov 2011 at 4:41am
it sounds like you want something like this:
shared numbervar LA;
local numbervar dLA:=distinctcount({table.field}, {group});
LA := LA + dLA;
dLA
 
I am just not sure how you will get the LA specific entities, but this will display the distinct count in the department footer and in the report footer you would have something like:
shared numbervar LA;
LA
 
and this will display the sum of the distinct counts in the report footer.
IP IP Logged
achandana01
Groupie
Groupie
Avatar

Joined: 20 Jul 2011
Online Status: Offline
Posts: 59
Quote achandana01 Replybullet Posted: 23 Nov 2011 at 1:21pm
Your formula is working really well in getting the totals by department however I just forgot to include a condition at the department level I need to be break down by each city
 
shared numbervar LA;
local numbervar dLA;
if(city = "LA")=distinctcount({table.field}, {group}) ;
LA := LA + dLA;
dLA
 
Does this work or will that be a separate condition
chand
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 28 Nov 2011 at 5:00am
depends on how your report is structured...it's been a long weekend so details are fuzzy.
 
if you are displaying the count, by department and city, you probably just need to have a formula like:
shared numbervar LA;
shared numbervar xx;
 
local numbervar dc:=distinctcount({table.field}, {group});
if city = "LA" then LA := LA + dLA
else if city = "XX" then xx := xx + dc
  else...
dc
 
 
but if you are doing the subtotal somewhere else the formula would be different.
 
with the above method, you would display in the summary by creating formulas like:
shared numbervar LA;
LA
 
HTH
IP IP Logged
mini987
Newbie
Newbie


Joined: 01 Dec 2011
Location: Croatia
Online Status: Offline
Posts: 8
Quote mini987 Replybullet Posted: 01 Dec 2011 at 9:46pm
hello!
i have also problems with total sum

my table looks like this

paper                                   number
sora press_80_70x100        28 600
imitex_140_70x100              340
sora press_80_70x100        28 600

what I need is to sum the same paper in the new column, and that that looks like this

paper                                   number           sum
sora press_80_70x100        28 600
imitex_140_70x100              340
sora press_80_70x100        12 000           40 600


can you please help me??

IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 02 Dec 2011 at 3:22am
this becomes complex...
most of the time when you do a running total it's a total for a group, but here you want to have individual running totals by item, which is a bit more complex.
 
I have 2 possible solutions, neither of which is completely simple:
1) create a delimited string listing the item and its total which is maintained by adding/modifying the string
2) creating 2 arrays, 1 to hold the item and the second to holds it total
 
you may need to reset these methods as well, but from the snippet above, you wouldn't.
 
the delimited string would be something like |itemID^currentTotal|item^currentTotal|...
 
so you would use instr(totalString, "|" + {table.itemID} + "^") if this is > 0 then you would want to retrieve from initial pipe (|) to the next pipe and string current value, update it, display it, and then re-encode the value and insert it back into the string.  If the instr() = 0 , then you would just encode and add to the string.
 
if you are using arrays, you would initially dim 2 arrays to a size that is large enough to hold the items, say 100 or so to start.  (we can dynamically resize the array, but initially I would try to stay away from that).  Then you would search one of the arrays for the itemID, and if you find it, you can look in the other array at the same index for the value, increment it, display it, and just update the array.  If you don't find the itemID, you update the 'last' array element to hold the new itemID and update the count in the other array for the same index.
 
Neither is simple, but neither is it impossible.
 
HTH
IP IP Logged
Page  of 2 Next >>
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.031 seconds.