I want to show my Grand Total values by using a specific formula field.
Actually I want to sum formula fiel such as :
sum(#ClosingBalance)
But It gives a message
This Field Can not be summarize
How can I solve this problem ??
I solved my problem,
I explain below how can I solve this,
I need two other function to show grand total in my report footer, where I use formula field as my summarized field.
so, firstly I create a function name #Grouptotal by using below formula
Numbervar x:=x+{#ClosingBalance} And place it in my group footer
Then I create another formula name #GrandTotal and place it in my report footer
Numbervar x:={#Grouptotal}-{#ClosingBalance}
Finally I suppress the #Grouptotal Field , and get the result of #GrandTotal By using Formula Field.
Thanks a lot...
Yes, you can do this using variables.
Step 1: Create a Formula Field Named as Sum1:
Shared numberVar Sum1;
Sum1 := (Your Table Field) + Sum1;
Place this one in Details section and suppress it (Right Click Formula --> Format Field --> Common --> Suppress).
Step 2: Create another formula to display the result as PrintSum1:
Shared numberVar Sum1;
Sum1;
Place this formula in Group Footer and suppress it (Right Click Formula --> Format Field --> Common --> Suppress).
Step 3: Create another formula field:
Shared numberVar GrandTotal;
GrandTotal := GrandTotal + {#Sum1}
This way you can summarize a formula field. Place this one in group footer.
Step 4: Create one last formula as Clear:
Shared numberVar Sum1;
Sum1 := 0;
Place this formula in Group Header and suppress it. This is to clear the Sum1 value for every record or group.
Let me know if you have issues.
Related
How do I add a running total or summary field on a formula field in crystal reports?
// Sample Report
Serial No. Premium Commission Net (Premium-Commission)
-----------------------------------------------------------------------------
1. 10 4 6
2. 40 30 10
---------------------------------------------------------------------------
Grand Total 50 34 16
In sample report, Net (Premium-Commission) is a formula field which gets evaluated for each row? How do I add a grand total/summary field for my formula? It seems we can add a summary field to only Command fields.
Suppose Net (Premium-Commission) formula field name is {#Net}. Now you have to create another three formula fields.
Initializer: this formula filed will be placed in header section to reset all variables.
Increment: this formula field will be placed in detail section to summarize the value.
Total: this formula field will be placed in footer section to show total of {#Net}.
Code will be writen in formula fields as below.
{#Initializer}
WhilePrintingRecords;
Numbervar dSum :=0;
{#Increment}
WhilePrintingRecords;
Numbervar dSum; //Don't initialize zero
dSum:=dSum+{#Net}; //{#Net} formula field must be return numeric value
{#Total}
WhilePrintingRecords;
Numbervar dSum; //Don't initialize zero
dSum;
Place all formula fields in their appropriate section and suppress {#Initializer} and {#Increment} formula field.
If you are using any calculation then that is not possible but one workaround would be to sum the each row and reset it in header.
Create a formula #Intialize in that write below code:
Shared NumberVar count;
count:=0
In detail write below formula and place it after Net (Premium-Commission).
Shared NumberVar count;
Count:=count+<>
\
3. Now create one more formula #Display and place it in footer.
Shared NumberVar count;
count;
I have a very basic report with no groups. The details consists of a number of numeric columns. I want to add a formula field which will use a field from the first row. Example:
(ColumnAFromCurrentRecord - ColumnBFromFirstRecord) / ColumnBFromFirstRecord
Can someone point me in the right direction?
1.
Create a formula named AssignFirstValue and define it like this:
WhilePrintingRecords;
Global StringVar strFirstValue := {MYDBNAME.MYSTRINGFIELD};
Put the AssignFirstValue formula in your Report Header and suppress it.
2.
Create a formula named PrintFirstValue and define it like this:
WhilePrintingRecords;
Global StringVar strFirstValue;
strFirstValue
Put the PrintFirstValue formula wherever you want to display the first value in your report.
you need to extact the column b from first record. try below solution.
Note: This is not a tested solution as I at present I don't have CR.
create below formula Count and place in detail section:
Local NumberVar a;
a:=a+1;
This will number the rows starting from 1 to the last row.
Now create one more formula StoreB:
Share NumberVar b;
if {#Count}=1
then b:=columnb
This will store the value of columnb in first record in variable b
Now use where you want:
EvaluateAfter(#StoreB)
Shared NumberVar b;
(ColumnAFromCurrentRecord - b) / b
Let me know how it goes.
I am trying to create a formula in Crystal Reports which would return the grouping field depending on what group the formula is placed. For example, if the formula inserted in the group row 'Month', the formula should return ‘command.month’. If the formula inserted in the group row 'Year', the formula should return ‘command.year’. Can anyone help with this, please?
Thank you.
If your date field format is MM/DD/YYYY then you can use below condition in Formula field. and use this formula field in grouping.
if {YourGroupFieldValue }='month' then
left({DateField}',2)
else if {YourGroupFieldValue }='Day' then
mid ({DateField}',2,2)
else
right({DateField}',4)
It should work because i have used it.
Consider you have two groups Month and Year. Add one formula in month group. In that formula create a shared variable as shown below.
Shared numbervar num:=0;
Create another formula in Year group. In that formula create a same shared variable as shown below.
Shared numbervar num:= 1;
Now create third formula, in that formula add below declaration.
Shared numbervar num;
if num = 0 then {your logic}
else if num =1 then {your logic};
Put your third formula in both groups and run the report. Same formula will show different values in different groups. I hope I got you this time... :)
I have the following formula: #Sales_Cost
(Sum({Estimate_Retail_Inventory_Change___Detail.Sales_Ret_Final_Amount}, {Estimate_Retail_Inventory_Change___Detail.Inv ID}) -
(Sum ({Estimate_Retail_Inventory_Change___Detail.Sales_Ret_Final_Amount}, {Estimate_Retail_Inventory_Change___Detail.Inv ID}) *
{#GM%_For_Cost_Sales}))
This produces the following results and I have placed in my GH2 section:
592.77
1038.26
2628.38
3598.62
356.58
I want to total those values for my Report Footer, but I get the error message, "This field cannot be summarized".
How do I do this?
You need to create a manual running total. To do this you will create 3 new formula fields.
The first one goes in the report header to initialize the running total variable.
WhilePrintingRecords;
NumberVar manualTotal :=0;
The second one goes in the group header with your summary formula.
WhilePrintingRecords;
NumberVar manualTotal := manualTotal + {#Sales_Cost};
The third one goes in your report footer to display the calculated value.
WhilePrintingRecords;
NumberVar manualTotal;
manualTotal;;
Assuming {#GM%_For_Cost_Sales} will not vary within each Inv Id value (though it could vary across different values) and that the group for GH2 is on Inv Id, the simplest way to do this would be to change your formula item to:
{Estimate_Retail_Inventory_Change___Detail.Sales_Ret_Final_Amount} *
(1 - {#GM%_For_Cost_Sales})
- and place summed #Sales_Cost fields into both your GH2 group header and report footer sections.
Hi i have a long formula field which I would like to include as the cross tab report summary field. However after I define the formula field I don't see it in my crosstab screen. How to include it ?
Here is my formula field
WhilePrintingRecords;
numberVar rt;
numberVar layMdp;
numberVar totMdp;
rt=Round(({Command.GENGNPIAMT}/{Command.TOTALGNP})*100,2);
layMdp:={Command.GENPREMMDP};
totMdp:=(layMdp)*Truncate((rt/100),4);
Also if I place this formula field inside details section, it shows a zero. Why is it not calculating anything ? I like it to calculate values as per each cross-tab column.
You're setting the variables but the formula itself is not returning anything. If you want to return the value of totMdp, just add it after the last line:
WhilePrintingRecords;
numberVar rt;
numberVar layMdp;
numberVar totMdp;
rt=Round(({Command.GENGNPIAMT}/{Command.TOTALGNP})*100,2);
layMdp:={Command.GENPREMMDP};
totMdp:=(layMdp)*Truncate((rt/100),4);
totMdp