Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: need to sum only specific sub-groups Post Reply Post New Topic
Author Message
shatcher94
Newbie
Newbie
Avatar

Joined: 14 May 2015
Online Status: Offline
Posts: 8
Quote shatcher94 Replybullet Topic: need to sum only specific sub-groups
     Posted: 05 Jun 2015 at 3:08am
I have a report that is grouped by job number(5 characters) then account number(4 characters) then sub account number(2 characters). at the bottom of each job number group I need to show the sum of all the account numbers that start with a 7 then a sum of all the other account numbers. I have no idea how to do this. please help!
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 05 Jun 2015 at 3:58am
by sum do you mean you are summing a value from details?
ther are  afew ways to do this.
If you only looking to display the sums you can create a formula for grouping in a Crosstab you can disoplay in teh report footer or header
if left(totext(table.accountnumber,0,""),1)="7" then "7 description here" else "not 7 description here"
Use that to create a group in a CT and do a sum on the field you want summarized
 
or create two formulas and sum each one
//seven
if left(totext(table.accountnumber,0,""),1)="7" then tableamountfield else 0
 
//notseven
if left(totext(table.accountnumber,0,""),1)<>"7" then tableamountfield else 0
 
and do a sum of each of these
IP IP Logged
shatcher94
Newbie
Newbie
Avatar

Joined: 14 May 2015
Online Status: Offline
Posts: 8
Quote shatcher94 Replybullet Posted: 05 Jun 2015 at 4:11am
yes, in this situation each record has a job # field, an account # field, a sub account # field, and an amount field. with the largest grouping being the job number field. at the bottom of each job number group is where i wanted to display the sums for all the records with an account number that starts with 7.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 05 Jun 2015 at 4:15am
create the formula
 
//seven
if left(totext(table.accountnumber,0,""),1)="7" then tableamountfield else 0
 
sum this at the group level
 
or use a running total
name= HasSeven (or whatever)
field to summarize = amount field
type = sum
evaluate = use a formula
left(totext(table.accountnumber,0,""),1)="7"
reset = on change of group (select correct group)
place in the group footer - RTs do not work in headers
IP IP Logged
shatcher94
Newbie
Newbie
Avatar

Joined: 14 May 2015
Online Status: Offline
Posts: 8
Quote shatcher94 Replybullet Posted: 05 Jun 2015 at 4:41am
should that be a formula field? or what type of formula. when I check the formula for errors, it tells me "too many arguments have been given to this function"
IP IP Logged
shatcher94
Newbie
Newbie
Avatar

Joined: 14 May 2015
Online Status: Offline
Posts: 8
Quote shatcher94 Replybullet Posted: 05 Jun 2015 at 4:45am
when i entered the formula in this format it came back with no error. the table name is dummy

if left(totext({dummy.accno}),1)="7" then {dummy.amnt} else 0

then when i sum this at the bottom of the job# group it works

Edited by shatcher94 - 05 Jun 2015 at 4:49am
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 05 Jun 2015 at 5:32am
for clarification, are you are all set or you need more help on this?
IP IP Logged
shatcher94
Newbie
Newbie
Avatar

Joined: 14 May 2015
Online Status: Offline
Posts: 8
Quote shatcher94 Replybullet Posted: 05 Jun 2015 at 5:46am
all set, thanks so much for the quick response!
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