Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Technical Questions
Message Icon Topic: Totals of YTD and Monthly in the same report? Post Reply Post New Topic
<< Prev Page  of 2
Author Message
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 01 Nov 2012 at 10:28am
sorry, this got mucked up somewhere along the lines
For thismonths data you use
 
if {Gf.Gf_Date} in monthtodate then {GfFnds_1.GfFnds_1_Amount) else 0
 
for last months data you use
if {Gf.Gf_Date} in lastfullmonth then {GfFnds_1.GfFnds_1_Amount) else 0
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 01 Nov 2012 at 10:29am
if you need it to choose between the two I need to know what condition sets the choice.
IP IP Logged
bholt
Newbie
Newbie


Joined: 30 Oct 2012
Online Status: Offline
Posts: 16
Quote bholt Replybullet Posted: 05 Nov 2012 at 6:54am
if {Gf.Gf_Date} in monthtodate then {GfFnds_1.GfFnds_1_Amount) else 0
for last months data you use
if {Gf.Gf_Date} in lastfullmonth then {GfFnds_1.GfFnds_1_Amount) else 0
 
Oookay, thanks for clarifying. That was really helpful. Ok based on the formulas above here is what I came up with, and it seems to be working (in the sense that there are no errors according to CR), however the amount is equal to zero, which is definitely not correct. Any idea why that might happen?
if {Gf.Gf_Date} in lastfullmonth then Sum ({GfFnds_1.GfFnds_1_Amount}) else 0
Then for the % I did:
 
if {Gf.Gf_Date} in lastfullmonth then Sum ({GfFnds_1.GfFnds_1_Amount}) else 0 % 37500
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 05 Nov 2012 at 8:13am
do not use an if-then on a sum.
You cannot conditionally summarize like this. That can be accomplished via Running Totals or shared variables but that is a different approach.
 
Try to reverse your thinking. What ew are doing is converting your row level data to be either the row value or a 0. Now if you sum ALL of these it would be the same total as if you had only summed some of them because you are zeroing out all of the ones you did not want to include.
 
Lets call the first formula "MTD_only"
if {Gf.Gf_Date} in monthtodate then {GfFnds_1.GfFnds_1_Amount) else 0
Place this on your detail section. You will see it 'zero out' all rows that were not part of this month.
now sum this formula field
this will show you the total for the currnt month only
now if you want to see it as a % add that to the summary
SUM({@MTD_only}) % 37500
 
Does that help?
IP IP Logged
bholt
Newbie
Newbie


Joined: 30 Oct 2012
Online Status: Offline
Posts: 16
Quote bholt Replybullet Posted: 05 Nov 2012 at 11:15am
Aaaaaaaah! I think I finally get it!
 
Ok. I've got it working now, thank you so much!! Sorry it took a bit for me to grasp what you were saying.
 
Ok. The only other thing I'm unsure about is how do I get the monthly amount and % to be filtered by constituent code? Looks like it's just doing the total, and I need it to be separated out...

Thanks again!
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 05 Nov 2012 at 1:49pm
Just add in the group condition into the sum portion. It is the sum the field you are grouping on. Place it inthe group footer or header.
SUM({@MTD_only},{table.consituentcode}) % 37500
IP IP Logged
bholt
Newbie
Newbie


Joined: 30 Oct 2012
Online Status: Offline
Posts: 16
Quote bholt Replybullet Posted: 06 Nov 2012 at 6:40am
You are amazing! Thank you so much!!
IP IP Logged
<< Prev Page  of 2
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.