Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: conditional formula in group footer not working Post Reply Post New Topic
Author Message
bwsanders
Senior Member
Senior Member


Joined: 05 Sep 2012
Location: United States
Online Status: Offline
Posts: 177
Quote bwsanders Replybullet Topic: conditional formula in group footer not working
     Posted: 19 Feb 2013 at 7:09am
i'm using a formula in my group footer which is basic.

If {field} = 1 And {field} = 2 Then -(Sum({field}))

when i run the report it's coming up with some super crazy number that i can't even find anywhere in the report to see how it's making this number.

i can force it to pass through anything i tell it {field} is equal to but i'm stuck on why the formula isn't working.


any thoughts?

any help would be great!

thank you!

IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 19 Feb 2013 at 7:53am
placing a field in the gf just means it is evaluating for the last row in the group. your THEN portion is the opposite value (+/-) sum off all rows in the report
IP IP Logged
bwsanders
Senior Member
Senior Member


Joined: 05 Sep 2012
Location: United States
Online Status: Offline
Posts: 177
Quote bwsanders Replybullet Posted: 19 Feb 2013 at 8:18am
well, i thought that only when i manually sum all the rows it's coming up with a number way less.

what i tried was switching up the formula to

Select {ELaborDist.det}
    Case "T"
    : (
        If {ELaborDist.cd} = "D" Then
            Offset := Sum({ELaborDist.amount}) * -1
        );

it's still giving me the same figure for each group footer which is nowhere near the number it should be returning.

thoughts?
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 19 Feb 2013 at 8:38am

I think you are interpretting these sum functions as an action on that row.

it is for all of the rows in the report. It does not add them per row.
From your variosu posts I think you are trying to alter each rows data and then add that value to the next altered row.
that is usually done via shared variables or you can alter the base value in row and then do a summary on that formula.
IP IP Logged
bwsanders
Senior Member
Senior Member


Joined: 05 Sep 2012
Location: United States
Online Status: Offline
Posts: 177
Quote bwsanders Replybullet Posted: 19 Feb 2013 at 9:02am
yes, you are correct. this is a GL import file for a client that i'm working on and have gotten the data in the rows and have it assigned values then need to show it summed per group based on the above formula. i am using shared variables throughout the report i'm just not sure on how to show the sum i'm looking for in the footer for each group. 
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 19 Feb 2013 at 9:43am
sum(field,groupfield) will give you the value of the field per group
IP IP Logged
bwsanders
Senior Member
Senior Member


Joined: 05 Sep 2012
Location: United States
Online Status: Offline
Posts: 177
Quote bwsanders Replybullet Posted: 19 Feb 2013 at 9:58am
Thank you! it is now summing per group although it is negating the formula and just giving me the sum. it should be returning the sum of the fields outlined in the code here:

Shared NumberVar Offset;

Offset :=

Select {ELaborDist.det}
    Case "T"
    : (
        If {ELaborDist.cd} = "D" Then
            Offset := Sum({ELaborDist.amount}, {EPayHist.id}) * -1
        );

epayhist.id is the group and it should only sum the total of elabordist.amount where the other columns are 'T' and 'D'.

i really do thank you for your help. i'm racking my brain over here.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 19 Feb 2013 at 10:30am
as ai stated before your formual is only evalauting on the last row of data for the group, it is not a per row condition.
In order to to that you have to use shared variables (per row) or running totals with evaluation formulas.
I think you want something more along the lines of 3 formulas,
one to set the value to 0 in the gh
a second to add your values
and a 3rd to display the final sum in the gf
I think you are trying to do all 3 in one formula
 
gh
Shared NumberVar Offset;

Offset := 0
 
detail
Shared NumberVar Offset;
Offset := offset + (If {ELaborDist.cd} = "D" Then {ELaborDist.amount})
 
gf
Shared NumberVar Offset;
Offset := offset *-1
offset
IP IP Logged
bwsanders
Senior Member
Senior Member


Joined: 05 Sep 2012
Location: United States
Online Status: Offline
Posts: 177
Quote bwsanders Replybullet Posted: 19 Feb 2013 at 10:53am
the part that i was missing the was the gf pass through.

DBlank you are awesome!

thank you!
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