In Crystal Reports, what is the difference between a running total field and a summary field?
(In the Crystal IDE, Summary fields are located in Insert -> Summary. Running totals can be added in the Field Explorer)
(Version 11.5)
In my experience, Running Total fields are basically enhanced Summary Fields.
Running Total fields can do everything Summary Fields can, except that Running Total fields can also do the following:
Evaluate for each record, on change of field, on change of group, or evaluate based on a formula.
Reset the summary on change of field, on change of group, based on a formula, or never.
Summary Fields, however, can be shown as a percentage of a field, so they're not without their uses (and they're a little easier to set up).
Related
I want to sort my report by ticketCost, but the regular summary of sum is got the total of all record include duplicate records.
The left field is a Summary and the right field is a Running Total. Only the Summary shows up when I go to configure the group, it only allows me to pick the Summary.
How can I sort on a Running Total? Or is there some other way to use a Summary to avoid duplicated records?
Crystal reports have two stages: the Reading stage and the Printing stage. Your Running Total fields are evaluated during Printing, but Grouping occurs during Reading. This is why you can't group on a Running Total - it won't be ready by the time Grouping needs it to be.
The best way around this is to perform the calculations is to write a custom SQL statement in the Database Expert.
This will return a new table in which you can calculate ticketCost as a field even before it reaches the report. Then group based on the new ticketCost field.
I am really new to Crystal Reports and I am looking for any suggestions on how to approach the following issue:
I currently have a report that uses a record selection to limit the results by date. I would like to include in this same report a summary a total count of all the records (ignoring the record restriction). Unfortunately (although somewhat expected), the summary calculates the total after the record restriction is applied. Is there any way to get around this? In case my question is a bit unclear I've included a generic example below:
I have a report that pulls info from a database with a total of 10 records.
I select a specific date range, and it only returns 3 records
I would like to include in the report footer that 3/10 records are getting returned.
This is bit tricky to perform in crystal reports as record selection is compulsory applied. However you can overcome this by using sub report.
Calculate the report footer using report.
This will surely work
I have a crystal report which has a running total field, i want to look what is the formula that running total field is using? I have never used crystal reports am debugging with that now.
In other words how do i edit existing running total fields?
On the left hand side of the screen should be the Field Explorer. In that list is a group called 'Running Total Fields'. If you expand that list you'll see all running total fields for a report. If you right click one of those fields one of your options is 'Edit'.
The edit box has a whole bunch of different options. Summarizing a field by sum, or average, or minimum, maximum, etc. etc. etc.
You can also just find where the running total is being used in the report and right click the field its self to bring up the 'Edit' GUI.
If you're asking about code at a deeper level than this GUI, that is not revealed to the end user outside of this GUI/Wizard style format.
In some inherited code, I see group headers/footers have items like 'Sum of #numcount' . I cannot get the sum of a formula field. Any thoughts?
The only reason that I know of why a formula wouldn't be available to summarize on is if it didn't reference any database fields or whose value wasn't dynamic throughout sections of the report. For example, if you have a formula that returns a constant it won't be available. Or if it only references a field that is set throughout the report and returns a value based on that field, like "if {parameter}=1 then 1" would not be available either.
In general, the formula's value should not be static through the sections of the report you're summarizing over (Though the way Crystal determines this is beyond me and this doesn't seem to be a hard and fast rule)
EDIT: One other reason why a formula wouldn't be available is if you're already using a summary function in that formula. Only one level of summaries at a time!
(Assuming you are looking at the reports in the Crystal Report Designer...)
Your menu options might be a little different depending on the version of Crystal Reports you're using, but you can either:
Make a summary field: Right-click on the desired formula field in your detail section and choose "Insert Summary". Choose "sum" from the drop-down box and verify that the correct account grouping is selected, then click OK. You will then have a simple sum field in your group footer section.
Make a running total field: Click on the "Insert" menu and choose "Running Total Field..."*** Click on the New button and give your new running total field a name. Choose your formula field under "Field to summarize" and choose "sum" under "Type of Summary". Here you can also change when the total is evaluated and reset, leave these at their default if you're wanting a sum on each record. You can also use a formula to determine when a certain field should be counted in the total. (Evaluate: Use Formula)
You Can simply Right Click Formula Fields- > new
Give it a name like TotalCount then Right this code:
if(isnull(sum(count({YOURCOLUMN})))) then
0
else
(sum(count({YOURCOLUMN})))
and Save then Drag and drop TotalCount this field in header/footer.
After you open the "count" bracket you can drop your column there from the above section.See the example in the Picture
You can try like this:
Sum({Tablename.Columnname})
It will work without creating a summarize field in formulae.
I have a problem with running Total in Crsystal report9
if their is no values available for a Paticular field how can we return the running total as '0'
Instead of display the Running Total directly in your report create a Formula Field based on the Running Total and drag it into the report.
Your formula should look like this (Crystal Syntax)...
if ISNULL({#RunningTotalField}) then
"0.00"
else
ToText(RunningTotalField, 2)
If there is no data for that particular group, then Crystal won't show it easily. Your options are :
1) Use subreports to display the values for a particular group, and keep the main report just looking at the table(s) containing the group headers.
2) Use a stored procedure as the source so you have full control over the SQL that is run.
The problem is that as soon as you use a field to group, Crystal will only return records where that field has been used. If it was simply in the Details section you could modify the link to a LEFT JOIN and it wouldn't matter, but the group forces the INNER JOIN which means the groups without data are not returned.
Unfortunately Running Totals don't show up if there are no records that match your criteria. An alternative is to use a set of formulas calculated in various sections of the report. The technique is widely described in the Crystal literature. For example, this TekTips gives a very succinct overview of your options.
You set up an initialising formula in each header, with the evaluation time directive "WhilePrintingRecords". This approach was the only one available for doing running totals in the "good ol' days" before RunningTotal objects were available.