How to get individual group totals in report - jasper-reports

I have a jasper report being made with iReport, which is basically a list of pages received the day prior. The report has total pages for the whole day and then individual totals for each group of page types.
The requirements state I need to display all the totals above the listed records and groups (ex. display in the title band). I created a variable for the total of all pages and that works but am having trouble getting each individual group total.
It should look like:
Total pages received: 50
Total GROUP_A: 20 Total GROUP_B: 30
When I try to use the variable set up for group totals, it only gives me the last used group, so it would say 30. I'm unsure how to create a variable to get the total for only a specific group.
I could include in my SQL result set the totals but was asked to do it within iReport.

If I understand the problem right you need to put a copy of the variable that you are using in the group and put it in your title band. the trick is on the object in the title band make sure you have set the evaluation time & evaluation group group or report depending on what you are truing to get a total of.

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.

Calculating totals from formulas that represent different groups

I have a Crystal Report that shows different groups(or departments) utilizing the groups in Crystal Reports. I then used some formulas to calculate Attached and Unattached assets in each group. Now I wish to show a total for the column of Attached and Unattached, what is the best and simplest way to do this?
Update
Okay I have been able to use a running total on #countattached that gets me close to what I need, the only problem is that it wants to add the last group total to the next group. The report is set up so the Employee (I.E. Jane Doe) and under that Employees name are Groups that, that Employee adds reports too such as Parks, Water, Streets , Etc. those Groups have a field across from them for Attached and Unattached with a total for both together at the end for each Group. I need a total for each Group under the column of attached and Unattached..
CrystalReport
Okay I finally figured it out if you have a series of columns that have sums for individual groups(parks,streets,water) under employees all you need to do to calculate the totals of those groups is right take the formula that has the sum for those groups, , such as (#countAttached). Then do a Running Total in the Running total dialog box, you can then set it to reset after each individual that those groups apply to then you have a those totals for that column. You just repeat this process for any other Columns you have.

Print field from first record in a group in the group footer

I have a series of transactions that contain a receive and return date and are grouped. In the group footer, I want to print the receive date of the first record in the group and the return date of the last record in the group. I created a formula to populate only when it is the first record in the group. But if the group contains more than one record, the formula field prints out blank. If there is only one record in the group, it prints OK. I'm using SAP Business Object Crystal Reports 2013.
There are a few ways to handle this. If you were sorting by Date, (which I've just learned you aren't) you could use a Summary to find the Minimum value. You'd place it in the relevant Group Footer and it should reset each time.
But since you're not sorting them by Date, I'd try setting up a Running Total that counts the number of records in the current Group (and resets on change of group.) Then set up a Shared Variable in a Formula that gets set every time the Group Count resets to 1. Finally, put another Formula in the Group Footer which prints out the Shared Variable.
Done correctly each Group Footer will display the first date value in that Group.

Crystal Reports 2008 running total using datediff returns only 1

I have a running total set to count employees with less than 30 days between two events. While the report has groups, I have the running total set to never reset. I am using a formula in the Evaluate section that is as follows:
DATEDIFF("d",{Employee.DATE_Event1},{Employee.Date_Event2}) < 30.
This running total returns 1 when placed in the report header and 1400 when placed in the report footer. 1 is far too low and 1400 is far too high. The requester wants the total in the report header. Thoughts?
if you keep your formula in header.. it will display 1st record and if you place in footer then it will display last record.. that is how it works.. so you get 1 and 1400...
You are trying to display a value when it is not actually calculated because as the running total reaches the footer value then you will get the fully calculated value....
what you can do is create a sub report and place it in header and supress the sub report... Perform the same calculation that you do in the main report and pass the sub report value to main report and take one more section of header after sub report section and display there your value..
With this approach load on database and report will increase as you are performing the same operation twice

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.