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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sum of entity totals

Status
Not open for further replies.

maas

Programmer
Sep 3, 2009
148
BH
Dear All,

I am having difficulties while calculating the total amount of each entity.

I am showing 3 account numbers and I am retrieving from the DB entities A, B, C for each account number(under each account).

For each entity there is an amount.

Now, I am trying to get the total amount for each entity, for example entity "A", I want to get the total amount for entity "A" for all the 3 accounts and place it in the page header.

Thank in advance for your help.

Regards
 
What you can do depends on the structure of your data, and how you group it. Please clarify.

A page header is a bad place to put data. Report headers can be used for summary totals. The use of Crystal's automated totals is outlined at FAQ767-6524.

It helps to give your Crystal version - 8, 8.5, 9, 10, 11 or whatever. Methods sometimes change between versions, and higher versions have extra options. In this case, it probably makes no difference.




[yinyang] Madawc Williams (East Anglia, UK). Using Crystal 10 & 11.5 with Windows XP [yinyang]
 
Dear Madawc,

I need to do this because this is the opening balance for each account.

Entity "A" is the opening balance for each account number. I need to get the total of Entity "A" in all the accounts, so this will be the opening balance and the report is depending on that field and i will do other calculations on that field.

I tried to use the formula :

If entity "A" = "OB" then

Sum (@balance)

It is giving me an error " the field can not be summarized" since the (@balance) is a formula and it is giving me the correct balances for each entity.
 
Do a field at detail level, something like
Code:
 If entity "A" = "OB" then {balance} else 0
It should be possible to create one or more summary totals from this.

[yinyang] Madawc Williams (East Anglia, UK). Using Crystal 10 & 11.5 with Windows XP [yinyang]
 
I am having 2 formulas to get the total which i placed in the group footer and they are giving me the correct values:

1.
whileprintingrecords;
numbervar sumpctx := sumpctx + {@Sum OB};

2.
whileprintingrecords;
global numbervar sumpctx;
numbervar DispSales;
DispSales := sumpctx;
sumpctx := 0;
DispSales;

now, I want to add the 2 formula in the header, but it is giving me 0 value, But in the group footer it is showing the correct value.

I tried to do:

Sum ({@Sum OB}) and it is giving that the field can not be summarized.

The group Name is @Entity which is grouped by.

@Entity :

if {Customer.NAME}="NONE" THEN
" OB"
ELSE {Customer.NAME}

Thanks in advance for yopur help.

Regards

 
What is the content of {@Sum OB}?

You should be able to create a formula like this:

//{@OB}:
if {@Entity} = " OB" then {table.amt}

Then use a formula like this in the group header:

sum({@OB},{table.acct})

...where {table.acct} is the field you are grouping on. If you want the total of OB for the entire report, remove the groupfield from the formula. You don't need to use variables for this.

-LB
 
{@SumOB}
if {gltnrpt.TRANS_TYPE}="OB" then {@Net_Dr_Cr}

{@Net_Dr_Cr}
Sum ({@dr amount}, {@CalcEntity}) - Sum ({@cr amount}, {@CalcEntity})

{@Entity} is the same as {@CalcEntity}
 
When asked to show the content of formulas, you should show the content of all nested formulas as well. I think your formula should be:

//{@OBdebit}:
if {gltnrpt.TRANS_TYPE} = "OB" then {table.debit}

//{@OBcredit}:
if {gltnrpt.TRANS_TYPE} = "OB" then {table.credit}

Then you can show a formula in the page header like this:

sum({@OBdebit})-sum({@OBcredit})

This assumes that you want the summary in the page header to be for "OB" across all accounts.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top