Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Subtract (sum fields) which are on report footer 2

Status
Not open for further replies.

mohsinhasan87

Programmer
Aug 1, 2012
12
AE
Hi,
I have one group on my report which has two fields Gross and Net.On details I have their details and on the group footer I have their summary as sum of both gross and net and on the report footer again sum summary of gross and net.

Eg:
Details :
Name Gross Net
ABC 100 200
XYZ 200 300
----------------
Group Footer:
300 500
----------------
Name Gross Net
DEF 200 300
----------------
Group Footer :
200 300
-----------------
Report Footer :
500 800

What I want to achieve is subtract report footer field
Eg: 500-800 = -300.

How can I achieve this? I tried this formula
sum({field1}) - sum(field2) but it says result should be boolean then I did this
sum({field1}) - sum(field2) > 0. No errors but also no data.
Please help .
Thank you
 
I am trying to use this as suggested by some users.I dont know what to use a Instance1? Further I have only one group which is string network name.When I save this formula it says "Result of selection formula must be boolean". What should I do?
whileprintingrecords;
numbervar A;
numbervar B;
if {dt_VU_GETMSG_SERVICE.FSERVICE_NETWORK} = "Instance1" then
A := Sum ({dt_VU_GETMSG_SERVICE.TOTALAMOUNT_}, {dt_VU_GETMSG_SERVICE.FSERVICE_NETWORK});
B := Sum ({dt_VU_GETMSG_SERVICE.AmountAfterSPShare_}, {dt_VU_GETMSG_SERVICE.FSERVICE_NETWORK});
 
not sure why this wouldnt work although I did notice you had () in one example instead of {}

sum({gross.field}) - sum({net.field})
for report footer

sum({gross.field},{group}) - sum({net.field},{group})
for group footer

_____________________________________
Crystal Reports 2008 and XI
Intersystems Cache 2012 ODBC connection

 
I think you are creating the formula in the wrong place. You need to create this formula in the field explorer->formulas->new:

sum({field1}) - sum({field2})

-LB
 
I used field explorer then created a new formula then under "Selection Formulas" > "Group Selection" I chose my sum fields and wrote this formula.
Sum ({dt_VU_GETMSG_SERVICE.TOTALAMOUNT_})-Sum ({dt_VU_GETMSG_SERVICE.AmountAfterSPShare_}) but it still says the result of selection formula must be boolean.
 
okay It worked. I was using expert all the time after creating new though I am not an expert. I used editor and it worked. Thank you so much.I have 2-3 queries as well, so shall I create a new thread or ask in this one?
 
I have one formula which shows the percentage according to gross we just calculated above. I used this formula to show percentage of gross.
shared numbervar rtTotal;
local numbervar thisTotal;
thisTotal :={dt_VU_GETMSG_SERVICE.TOTALAMOUNT_} % Sum ({dt_VU_GETMSG_SERVICE.TOTALAMOUNT_}, {dt_VU_GETMSG_SERVICE.FSERVICE_NETWORK});
rtTotal :=rtTotal+thisTotal;

and created a new formula for displaying the summary like this
shared numbervar rtTotal;
rtTotal;

but on my report it keep adding the record in the next field.
For Eg:

Details:
Name Percentage
ABC 20%
XYZ 29% ---> Original Value 9%
DFG 31% ---> Original Value 2%

At the end on group footer it shows 31%(last value).

I want to sum all the percentage field on details and show them on group footer.How can I achieve this?

Thank you
 
are you using the results of this formula in a subreport? You havent mentioned that. If you are not.... then I think (someone feel free to correct me if I am wrong) you are making your formulas more difficult than you need to.

If that formula is not being used except as you have explained then the following will get you the same result and read a little cleaner.. You dont need variable declarations

{dt_VU_GETMSG_SERVICE.TOTALAMOUNT_} % Sum ({dt_VU_GETMSG_SERVICE.TOTALAMOUNT_}, {dt_VU_GETMSG_SERVICE.FSERVICE_NETWORK})


_____________________________________
Crystal Reports 2008 and XI
Intersystems Cache 2012 ODBC connection

 
No I am not using the results on sub report.My main issue is I am not able to show the summary of percentage on group footer. I am able to show the percentage by simple formula as well the way you have mentioned but I need summary on group footer for that I have taken variables to show summary result on group footer.Using this formula

shared numbervar rtTotal;
rtTotal;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top