Crystal Reports, and running totals - crystal-reports

I am designing a report in which a Running Balance column adds itself to Debit and subtracts the answer from Credit column on every row. Here in this example I have started calculating from 1st of January. In this case, my Running Balance column will have zero.
Now my client wants to have a look at records from 17 January to the end. In that case, my cumulative balance will NOT be zero at first but instead it will calculate cumulative balance for all the dates before 17 January, and present it as the starting balance for 17th of January. I am stuck at this point. How to add all the record before 17th of January and show their Total in a single row.

There are lots of different ways to achieve this, but here's one idea you might like to try.
Set the report selection criteria to include all records from 01/01.
Create 2 report detail sections.
In the first detail section just place the running total and maybe a label: "Starting Balance".
In the second detail section place your normal fields.
In the section expert use a formula to suppress the first detail section: {table.date} <> {?date parameter}
In the section expert use a formula to suppress the second detail section: {table.date} < {?date parameter}
Hope that helps.

Related

Crystal reports - Can't filter on custom formula number field

Crystal reports don't let me use a custom count formula field to filter which transactions to show in a manager report.
I'm creating a Crystal report that team leaders are supposed to take out to see on how many occasions their employees have reported in sick. A record is only supposed to show if that person has reported in sick 6 or more times the last 12 months.
The report shows a record (a page) for each employee belonging to the managers organisational unit. Below the employee information is a subreport where I show the transactions from the salary/time system. Using select expert, I have filtered out the transactions that is supposed to show. I have then created a database field that count which day was 12 months back from today, and filtered so that only the transactions falling into this period shows.
My last problem is that I only want to show the record that has a minimum of 6 such transactions during the period. I created a formula field named #Antal ("amount" in Swedish) that simply counts the distinct number of dates in the "from"-date for the salary transactions I'm showing (since a change of law 2019-01-01 we needed to create a new transaction type, so some of the occasions after 2019 may have two transactions referring to one sick leave, thus I'm counting the first day of the period instead), DistinctCount ({P_LSTAT.P_SXXX06})
Now, the subreport has a new column with Antal (amount) that counts the amount of the desired salary transaction. I then try to use the selection formula to only show records where {#Antal} >= 6 but I get the following error:
This formula cannot be used because it must be evaluated later
Is there any other (better) way of doing this, or am I simply missing something?
For your selection based on {#Antal} >= 6 you need to use the group selection formula, not the record selection formula. Record selection is used to select records which meet the criteria before reading in the data. Group selection is used to filter out entire groups of records based on summarised values, after the records have been read in and the summaries calculated - which sounds like exactly what you need here.
The value of a Formula Field is out of scope when the Select Expert is evaluated.
There is no process for calculating the value of a Formula Field before it is printed within the section of the report it is placed. The Select Expert is evaluated prior to any section of the report being printed, so at this time all Formula Fields are effectively Nothing.

Crystal Reports formula based on group footer summary field

New to Crystal Reports -
I have a report with 3 columns - Estimated Hours, Actual Hours, Remaining Hours.
In the Group Footer it summarizes the hours by job. The remaining hours formula is {job.esthours}-{job.actualhours}. I want it to be blank if there is no estimated hours. I know that I can't use the sum of estimated hours in my formula but not sure what formulas to use.
Sample Report
You need to add a condition to suppress your formula in case the first cfield value is null. You can do it in two ways:
1) Add the condition in your Remaining Hours formula. Try this if you want blank also in your detail sections. Right-Click -> Suppress -> add there the next condition:
if(isnull({job.esthours}))
2) Add the condition in your Remaining Hours Summary. This is better if you wish to show negative values of Remaining Values in your Details Section for some reason. Right-Click -> Suppress -> add there the next condition:
if(isnull(sum({job.esthours})))
And yes, you can use the estimated hours summary, , you can find it in your Formula workshop, in the Report Fields tree

Crystal Report: Comparing 2 Years item performance based on QTY sold

I am new to crystal.
I have to show the top 217 items based on the quantities shipped in 2014 and side by side 2013.
Is there way to put in one report the data.
Item1 in 2103 may not be the same as 2014.
I get the data from invoice history detail table, and add the qty shipped from all item and then sort the top 217 items on basis of the sum.
I can have them in 2 reports or the previous year data from sub-report,but then the sub report data will appear as row after the current year. however how can I put them in 1 report side by side for a better comparison.
Thanks for your help
Steps:
Create a report that does what you want for a single year (say 2013)--you'll probably want to use a top-N grouping.
Create a second report, without a datasource
import the first report into the second one (call it 'year N-1'); don't link the sub-report to the main
import the first report into the second report a second time (call it 'year N'); don't link the sub-report to the main
edit the second sub-report and set the date to 2014
If you want the report to be more flexible, create a parameter in the main report (named 'year'). Link this parameter to each of the sub-reports, changing the respective, record-selection formulas to use the value to calculate the correct date ranges.

Daily average of count grouped by month

I am trying to figure out the best way to display the daily average of a count by month.
Here is what the data looks like
Date(date),Location(string),UnitID(string)
2011-12-1,A,123
2011-12-1,A,456
2011-12-1,B,789
2011-12-1,B,246
2011-12-2,A,135
2011-12-2,A,123
2011-12-2,B,789
2011-12-2,B,468
...
We would like a report showing the following:
(location) 12/2011 1/2012 2/2012 (by month)
A 12.5 10.3 14.0
B 22.1 20.9 25.6
The summary fields should be calculated following this general idea for each month/location combination:
Avg(Count(UnitID))/(days in month) *see below for clarification, this formula doesn't really make much sense.
The Avg(Count(UnitID)) is the tough part. A cross tab would work best, but anything at this point will work.
Any help is greatly appreciated.
Edit for clarity: The data is a listing of all units that had a failure. Several Units per day fail, spread out over several locations. In English what I want is the average daily number of failures of units per month, grouped by location.
I recommend doing this in a crosstab.
First, add a formula (called something like perMonthCount) like the following to the report:
1 / DatePart ("d",
DateAdd ("d",
-1,
DateAdd ("m",
1,
DateAdd ("d",
1-DatePart ("d", {failures.fail_date}),
{failures.fail_date}) ) ) )
Next, select Insert > Cross-Tab... from the menu and specify the following values in the Cross-Tab tab of the Cross-Tab Expert dailog:
Rows: your location field
Columns: your failure date field (use the Group Options button to specify that the column should be printed for each month, instead of the default for each day.)
Summarized Fields: the #perMonthCount formula field (the summary operation should default to Sum of.)
In the Customize Style tab of the Cross-Tab Expert dailog, check the Suppress Row Grand Totals tick-box. (You may also want to check the Suppress Column Grand Totals tick-box, if you don't want to see totals for all locations at the end of the report.)
Click on OK at the bottom of the Cross-Tab expert dialog and drop the Cross-Tab into the report footer.
You will also probably want to suppress the details section of your report.
At this stage, you should now be able to preview your results.

Conditional group SUM in Crystal Reports

I've been doing some accounting reports and have been summing up my different currencies using a formula
IE
CanadianCommissionFormula
if {myData;1.CurrencyType} = "CDN" then
{myData;1.Commission}
else
0
CanadianCommissionSum
SUM({#CanadianCommissionFormula})
Then I'd just display the CanadianCommissionSum at the bottom of the report and things were great.
I've just come across the requirement to do this, but grouped by Sales Rep. I tried using my previous formula, but this sums for the whole report. Is there an easy way to sum like this, based on which group it's in?
You probably figured this out a year ago, but just in case, try this:
Change your CanadianCommissionSum formula to
SUM({#CanadianCommissionFormula},{SalesRep})
Put this formula in your SalesRep's Group Footer section.
This should now display properly.
Create a group based on the sales rep in the Crystal Report, and place the:
SUM({#CanadianCommissionFormula})
...in the footer of the group.
I would assume that rexem's suggestion should work but since you said it gives you a total all of the sales reps you could change the sum to running total. Before doing this I'd double check that you have your field in the correct footer section though.
To do the running total, group by Sales Rep, and then set up your running total to evaluate on every record and reset on the change of the group. Then you can put this running total in the group footer and it will show subtotals.
Hope this helps.