Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Sum Data In a Grid Post Reply Post New Topic
Author Message
snoopsterg
Newbie
Newbie
Avatar

Joined: 04 Apr 2008
Location: United Kingdom
Online Status: Offline
Posts: 3
Quote snoopsterg Replybullet Topic: Sum Data In a Grid
     Posted: 10 Mar 2009 at 8:41am
Hey guys, thanks for looking in on this topic.

I am a little stuck as to how to do this. but hopefully someone will be able to help out.

I have a data set that comes from a SQL stored procedure, It is a set of sales order inputs which i need to Sum the different product groups. and have the shown in a grid by 3 monthly columns.


         Current Month      |   Current Month + 1    | Current Month + 2
        BGT | O/D | Orders    BGT  | Orders                BGT | Orders
CSF
OPF
C Clip


I am not sure how to write the formula to summarise the prod group.

Any help is most apreciated

regards

Steve
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 11 Mar 2009 at 7:23am
Not sure which are the product groups, but I am guessing CSF, OPF...since the data is coming from a stored proc, why not have the proc do the work? Build your return set so that for each product group you have columns for what you want on the report.
 
This way the heavy data manipulation is handled by a system that is really good at it, and Crystal just has to display...much easier than having Crystal manipulate everything.
 
Otherwise, I would say shared variables that are incremented based on the date and displayed in the group footer for the product group and reset to zero in the header.
 
Personally, I like having the stored proc do the work.
 
Hope this helps
IP IP Logged
snoopsterg
Newbie
Newbie
Avatar

Joined: 04 Apr 2008
Location: United Kingdom
Online Status: Offline
Posts: 3
Quote snoopsterg Replybullet Posted: 11 Mar 2009 at 7:35am
That sounds a much better idea, thank you, just need to figure out how to do that....

Yes the CSF and OPF are product groups, but we have about 14 of them, will this still be able to be done in a stored procedure... i have never done a Summing Stored procedure before.

Thanks for the ideas, i will go away and do some research, but if you have any links that would point me in the right dirction i would be more than happy..


Regards


Steve
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 11 Mar 2009 at 7:48am
You don't need to sum in the stored proc, though you could.  Just create a temp table of all of the product groups, then have a column for currentBud, NextBud, NextNextBud and use update to fill in the data.  (names are for example, but hopefully you get the idea).
 
When the data is returned to the report, the report can do the summing...or you can create a temp table from what you have now, then create a temp table of what you want to return (as described above) then you could update the data with something like
update #return
set (columns for current month) = (matching columns)
from #return
  join (select SUM(column you need1), SUM(column you need2), ProdGroup   from #currentDataLayout where (date range is correct) GROUP BY ProdGroup) ss ON ss.ProdGroup = #return.ProdGroup
 
Hope this helps.
IP IP Logged
snoopsterg
Newbie
Newbie
Avatar

Joined: 04 Apr 2008
Location: United Kingdom
Online Status: Offline
Posts: 3
Quote snoopsterg Replybullet Posted: 11 Mar 2009 at 8:00am
That is fantastic thank you, i will be going away and trying that.. if i need more help, In the immortal words of a fictional character " I Will Be Back"


Regards


Steve
IP IP Logged
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