Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Subtracting amount credit/debit Post Reply Post New Topic
Page  of 4 Next >>
Author Message
esther31
Groupie
Groupie


Joined: 19 Dec 2011
Online Status: Offline
Posts: 50
Quote esther31 Replybullet Topic: Subtracting amount credit/debit
    Posted: 22 Oct 2012 at 2:01am
Hello
 
I need to display the total of a sum based on a field value. I basically need to sum all records where a field = "Credit and all those where a field ="Debit" and then subtract the credit total from the debit total to get the overall total. Can you advise how to do this please. i've tried using groups, running totals and formulas but am getting myself in a mess. Any help would be greatly appreciated.
 
Thanks
Esther
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 22 Oct 2012 at 3:59am
tehre are a lot of ways to do this but if youa re not dealing with any duplicate data the easiest is to create 3 formulas to use.
//credits
if {table.typefield}='credit' then {table.amountfield}
//debits
if {table.typefield}='debit' then {table.amountfield}
//together
if {table.typefield}='credit then {table.amountfield} else {table.amountfield} *(-1)
 
now you can sum each of these at any grouplevel to get the values you want
IP IP Logged
comatt1
Senior Member
Senior Member
Avatar

Joined: 19 May 2011
Online Status: Offline
Posts: 337
Quote comatt1 Replybullet Posted: 22 Oct 2012 at 4:59am
Do you have to deal with voids? I do lots of accounting reports, and I get a little worried when I don't see voids in the logic
IP IP Logged
esther31
Groupie
Groupie


Joined: 19 Dec 2011
Online Status: Offline
Posts: 50
Quote esther31 Replybullet Posted: 25 Oct 2012 at 10:03pm
Sorry, I can't seem to get this to work
 
I have setup three formula fields:
 
credit: if {SRS_FDU.FDU_CORD}='C' then {SRS_FDU.FDU_AMNT}
 
debit: if {SRS_FDU.FDU_CORD}='D' then {SRS_FDU.FDU_AMNT}
 
together: if {SRS_FDU.FDU_CORD}='C' then {SRS_FDU.FDU_AMNT} else {SRS_FDU.FDU_AMNT} *(-1)
 
what do i need to do next?
IP IP Logged
esther31
Groupie
Groupie


Joined: 19 Dec 2011
Online Status: Offline
Posts: 50
Quote esther31 Replybullet Posted: 26 Oct 2012 at 1:35am
Hello
 
Sorry just to add, there may be multiple credit and debit records, will this still work?
 
Thanks
IP IP Logged
esther31
Groupie
Groupie


Joined: 19 Dec 2011
Online Status: Offline
Posts: 50
Quote esther31 Replybullet Posted: 29 Oct 2012 at 12:56am
it may be that there are multiple credits and debits for one customer so for each customer i need to sum the credits, sum the debits and then sum the too and compare this amount to a different field. Any ideas please?
 
Thanks
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 29 Oct 2012 at 3:51am

as you created each of the formulas did you place it on the detail row to make sure it was giving you the correct value per formula per row?

if so then you just need to insert a summary as a SUM for each of the formulas at each of the footer levels you want to see results in.


Edited by DBlank - 30 Oct 2012 at 3:52am
IP IP Logged
esther31
Groupie
Groupie


Joined: 19 Dec 2011
Online Status: Offline
Posts: 50
Quote esther31 Replybullet Posted: 30 Oct 2012 at 12:39am
Hello
 
This isn't working and i'm now getting myself completely confused!
 
If i've grouped by customer ref where should i be putting the forumals? None of them seem to be calculating correctly.
 
Sorry for being a complete novice!
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 30 Oct 2012 at 4:04am

create one formula called "credits"

if {SRS_FDU.FDU_CORD}='C' then {SRS_FDU.FDU_AMNT}
place it on the detail section.
when you preview the report you should see the actual credit amount on every row that is a credit and a zero on all debit rows.
 
to get totals for just credits, click on the sigma sign (the blue E in the toolbar) to insert a summary.
select the "Credits" formual field
calculate as a SUM
Summary location will be group 1 (customer)
this will create a field in the group footer that is the sum of credits for each customer.
If you want a sum for the whole report repeat teh last step put for the summary location select Grand Total (report footer) as the location.
 
Repeat the process for "Debits" using
if {SRS_FDU.FDU_CORD}='D' then {SRS_FDU.FDU_AMNT}
 
finally create the "Together" using
if {SRS_FDU.FDU_CORD}='C' then {SRS_FDU.FDU_AMNT} else {SRS_FDU.FDU_AMNT} *(-1)
when you place this on the detail row you should see the amount on eery row but if it is a credit is is a positive value if it is a debit it is a negative value.
 
IP IP Logged
esther31
Groupie
Groupie


Joined: 19 Dec 2011
Online Status: Offline
Posts: 50
Quote esther31 Replybullet Posted: 31 Oct 2012 at 1:18am
This works perfectly, thank you for you patience and help! I now only want to display records where this summary is not equal to another field {SRS_SFE.SFE_CFEE}, if i try and do a simple suppresion where the fields are equal it says 'a number is required here'
 
Any ideas?
 
Thanks
 
IP IP Logged
Page  of 4 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.000 seconds.