Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Technical Questions
Message Icon Topic: Compare group totals Post Reply Post New Topic
Page  of 2 Next >>
Author Message
Evil McBad
Newbie
Newbie
Avatar

Joined: 06 Feb 2008
Location: United Kingdom
Online Status: Offline
Posts: 10
Quote Evil McBad Replybullet Topic: Compare group totals
    Posted: 28 Oct 2009 at 2:35am
Hi - I have a crystal report which reports from a database which has new records added each month.  The report is grouped, at the highest level, on 'Month' (this is a string field in the database - Eg "Aug", Sept" etc rather than a date field).
 
In the report, I  have a field, say 'X', which is summed at group level.  I wan't to compare this 'sumX' value for group 'September'  with the same value for group 'August'.
 
I thought previous (sum({x},{month}) would be the answer, but I get the error "no previous or next value"
 
Any ideas, guys?
Evil
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 28 Oct 2009 at 7:25am
use sum(x,{month})  and sum(x,{group})
 
As a thought, you might want to store the sum(x,{month}) in variable and then access that repeatedly...a little less on the calculating for CR.
 
HTH


Edited by lockwelle - 28 Oct 2009 at 8:01am
IP IP Logged
Evil McBad
Newbie
Newbie
Avatar

Joined: 06 Feb 2008
Location: United Kingdom
Online Status: Offline
Posts: 10
Quote Evil McBad Replybullet Posted: 02 Nov 2009 at 2:58am
Probably being dense here, but not sure what you are advising - the month is the group, so unsure what you mean by sum x, month & sum x, group.
 
Again, apoloies if I have misunderstood.
Evil
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 02 Nov 2009 at 6:29am

OK, I thought you wanted something different.  Do you always want to compare 2 consecutive periods?  If so, variables are the way to go.  you would need to set the 'last' period value at the time that you generate it, but you will need to have it lag, since you are also comparing at the same time.  like:

 
shared numbervar lastMonth;
local numbervar thisMonth:=sum({table.field},{group});
shared numbervar diff;
 
diff:=lastMonth-thisMonth;
lastMonth:=thisMonth;
thisMonth;
 
 
now you can display the diff at some other location in the report.
 
This is the general idea, you might need to fiddle with it to get it to work exactly as you want, but you get the idea.
 
HTH
 
 
IP IP Logged
Vertex
Newbie
Newbie
Avatar

Joined: 29 Oct 2009
Location: India
Online Status: Offline
Posts: 24
Quote Vertex Replybullet Posted: 02 Nov 2009 at 8:10am
IN THE BELOW CODE WHAT CODE IS USE FOR  ALL  RECORDS PARAMETER....


if {?Trial} ="This Month" then
{Order.CreateDateTime} in monthtodate
else if {?Trial} ="Last Month" then
{Order.CreateDateTime} in lastfullmonth
else if {?Trial} ="This Year" then
{Order.CreateDateTime} in yeartodate
else if {?Trial} ="Last Year" then
{Order.CreateDateTime} in lastyearYTD
else if {?Trial} ="All" then


....THANKS....
Hi Peoples
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 02 Nov 2009 at 8:14am
if {?Trial} ="This Month" then
{Order.CreateDateTime} in monthtodate
else if {?Trial} ="Last Month" then
{Order.CreateDateTime} in lastfullmonth
else if {?Trial} ="This Year" then
{Order.CreateDateTime} in yeartodate
else if {?Trial} ="Last Year" then
{Order.CreateDateTime} in lastyearYTD
else {?Trial} ="All"
IP IP Logged
Vertex
Newbie
Newbie
Avatar

Joined: 29 Oct 2009
Location: India
Online Status: Offline
Posts: 24
Quote Vertex Replybullet Posted: 02 Nov 2009 at 8:28am
FOR DISPLAYING DATE WITH RECORDS I USE TO FORMULA FROMDATE AND TODATE
HOW I CAN DISPLAY THE DATE FOR ALL RECORDS FOR BEGINNING DATE TO CURRENT DATE OF RECORDS...MY CODE IS HERE ....PLEASE GIVE ME CODE

else if{?Trial} = "This Week" then
( fromdate:=totext (dateadd('d',-weekday(currentdate),currentdate));
enddate:=totext (dateadd('d',-weekday(currentdate),currentdate)+7) )
else if {?Trial} = "Last week" then
( fromdate:=totext (dateadd('d',-weekday(currentdate),currentdate)-8);
enddate:=totext (dateadd('d',-weekday(currentdate),currentdate)-1) )
else if{?Trial} ="This Month" then
( fromdate:=totext(iStart);
enddate:= totext(DateAdd ('m',1,iDay-day(iDay)+ 1)-1) )

else if {?Trial} ="Last Month" then
( fromdate:=totext(iStart2);
 enddate:= totext(DateAdd("d",-1,iStart)) )

else if {?Trial} ="ALL" then



.......THANKS/..
Hi Peoples
IP IP Logged
Vertex
Newbie
Newbie
Avatar

Joined: 29 Oct 2009
Location: India
Online Status: Offline
Posts: 24
Quote Vertex Replybullet Posted: 02 Nov 2009 at 9:59am
FOR DISPLAYING DATE WITH RECORDS I USE TO FORMULA FROMDATE AND TODATE
HOW I CAN DISPLAY THE DATE FOR ALL RECORDS FOR BEGINNING DATE TO CURRENT DATE OF RECORDS...MY CODE IS HERE ....PLEASE GIVE ME CODE

else if{?Trial} = "This Week" then
( fromdate:=totext (dateadd('d',-weekday(currentdate),currentdate));
enddate:=totext (dateadd('d',-weekday(currentdate),currentdate)+7) )
else if {?Trial} = "Last week" then
( fromdate:=totext (dateadd('d',-weekday(currentdate),currentdate)-8);
enddate:=totext (dateadd('d',-weekday(currentdate),currentdate)-1) )
else if{?Trial} ="This Month" then
( fromdate:=totext(iStart);
enddate:= totext(DateAdd ('m',1,iDay-day(iDay)+ 1)-1) )

else if {?Trial} ="Last Month" then
( fromdate:=totext(iStart2);
 enddate:= totext(DateAdd("d",-1,iStart)) )

else if {?Trial} ="ALL" then



.......THANKS/..
Hi Peoples
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 02 Nov 2009 at 12:01pm
I already answered your question. You do not use the Fromdate or the todate. You just make it state {?Trial} ="ALL". This returns a TRUE value in the select expert. THis then has NO filtering on the DB which is equivalent to "all records".
IP IP Logged
Vertex
Newbie
Newbie
Avatar

Joined: 29 Oct 2009
Location: India
Online Status: Offline
Posts: 24
Quote Vertex Replybullet Posted: 21 Nov 2009 at 2:02pm
for sum of records of this current whole month what to do

sum ({Order.OrderID}, {Order.CreateDateTime}, "daily")

Hi Peoples
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.