Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Technical Questions
Message Icon Topic: Subtracting a field based another field's value Post Reply Post New Topic
<< Prev Page  of 2
Author Message
bigburb
Newbie
Newbie


Joined: 07 Oct 2009
Location: United States
Online Status: Offline
Posts: 26
Quote bigburb Replybullet Posted: 08 Oct 2009 at 9:48am
Aha! It worked! Thank you so much for your help!
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 08 Oct 2009 at 9:52am
Can you please post what the final solution you came up with that worked for you for future reference and readers?
Thanks Thumbs%20Up
IP IP Logged
bigburb
Newbie
Newbie


Joined: 07 Oct 2009
Location: United States
Online Status: Offline
Posts: 26
Quote bigburb Replybullet Posted: 09 Oct 2009 at 6:36am
Yes, I'll post it below, but now I have a new problem. My report is set up into 2 groups, employees by department, and employees by employee number. I had to add another variable just to add together the indirect hours only for each, employee, department and the report footer. It's adding up the employee totals correctly, but on the department and report total it is ignoring the last record. This happens for both the total indirect and direct, and the total indirect hours formulas.

This is what the group direct and indirect total hours looks like:

whileprintingrecords;
global numbervar nTotalHrsg:= nTotalHrsg + If isnull({jobtran.ind_code}) then {jobtran.a_hrs}
else if {jobtran.ind_code}='LUN'
    then 0 else {jobtran.a_hrs};

nTotalHrsg;



This is what the group indirect total looks like:

whileprintingrecords;
global numbervar nIndTotalHrsG1f:= nIndTotalHrsG1f + if {jobtran.ind_code}='LUN'
    then 0 else {jobtran.a_hrs};

nIndTotalHrsG1f;

Edited by bigburb - 09 Oct 2009 at 6:41am
IP IP Logged
bigburb
Newbie
Newbie


Joined: 07 Oct 2009
Location: United States
Online Status: Offline
Posts: 26
Quote bigburb Replybullet Posted: 12 Oct 2009 at 10:17am
OK, I've dug into the results a little bit, turns out the indirect total formula is right. What's actually happening is if the last record in the group or report is a direct transaction it adds it twice.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 12 Oct 2009 at 10:24am
variables are not my thing but I have seen the a double add on the last row and it usually has to do with the the last part of the statement and not using a seperate display formula.
If the 'fix' for why it was not working earlier at all was due to the ISNULL not being the first part of the if-then just swap out the formula from using the variable to:
If isnull({jobtran.ind_code}) then {jobtran.a_hrs}
else if {jobtran.ind_code}='LUN'
    then 0 else {jobtran.a_hrs}
and just use the SUM finction on that formula.
Does that do the trick?
IP IP Logged
bigburb
Newbie
Newbie


Joined: 07 Oct 2009
Location: United States
Online Status: Offline
Posts: 26
Quote bigburb Replybullet Posted: 12 Oct 2009 at 12:16pm
Wow that was a lot simpler than the running totals, I've submitted it to the controller (fingers crossed) hopefully it worked this time!
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.