0
votes

I have a Crystal Report of "SALES"
All are GROUPED AND SUMMED Daily,Weekly,and Monthly

I also have a Sub-report of "EXPENSES"

What I want to have is to have a Total SALES and EXPENSES for each GROUP FOOTER on the Main Report which would look like this

enter image description here

enter image description here

1
Which is Group Footer, where is SALES column? I can only find Expense.JulyOrdinary
I have my Main report on Sales. which has Product Name, Price, Product Sold and Total. Then I grouped it by "Transaction Date" though it is not shown in the table above, I grouped it by Daily, Weekly, and Monthly. My goal here is to be able to get the Net Income Per Day, Week, And Month by creating a formula. All that I need now is for me to be able to get the Daily, Weekly, and Monthly Expense on each Group Footer(Daily,Weekly,Monthly).Matt Pedrosa
Is the data in the Group being calculated correctly? Daily/Weekly/Monthly Groups have correct data in their footer? For some hint: Collecting from Header, may be it cab help for footer? answers.sap.com/questions/10769234/…JulyOrdinary

1 Answers

1
votes

I think a Shared variable will do the trick here. When creating variables in Crystal Report you can have a scope of Local, Global, or Shared. Local variables are in scope within a single formula or expression. Global variables are in scope within different sections of a report. Shared variables are in scope throughout the different sections of the report and any sub-reports as well.

Begin by creating a Formula Field in your Expenses sub-report. This formula field will need to create the variable and populate it with a value it reads from a field on your sub-report. Since I don't know the names of your fields, I will make one up called {Table.ExpenseTotal}. Now we can write the code for the formula field as follows:

WhilePrintingRecords;
Shared NumberVar expense := {Table.ExpenseTotal};

The next step is to place this formula field into the sub-report. It should be placed somewhere in the same section of the sub-report that contains the {Table.ExpenseTotal} field. This formula field will also display its value on the sub-report, so you will probably want to set its Suppress property to hide this field.

Now you will need to create a new formula field in your main report. The code for this formula field will be as follows:

WhilePrintingRecords;
Shared NumberVar expense;

The next step is to place this formula field into the main report. It must be placed in a section that follows the section containing the sub-report. At this time the formula field should be displaying the value of the expense variable that was created and populated in your sub-report.

To apply this to your report you will want to substitute the field that contains the Sum of expenses for the example field name I used.

There are some limitations to consider when using variables like this. These variables do not exist until the report is being printed, which is why the "WhilePrintingRecords" declaration is used. This means these formula fields may not be used in Summary Fields, Running Total Fields, or Record Selection because all of these are parsed before the report begins printing. You should also be mindful of which sections you place the Formula Fields within. The code for each variable is very simple usually, but the placement within sections and how Crystal Reports moves from section to section while printing is what determines the looping structure for how the values of your variable are updated.