I am trying to print the last record of the group but the expression print when group changes: True does not seem to work. It simply prints all the records of that group. (I've grouped the record based on username).
I was having trouble with the same issue. Here is the work around that I came up with:
JasperReports has some automatically generated variables that may help you achieve what you want. For every group you create there is a counter that keeps track of the number of items in your current group:
yourGroupName_COUNT
In your printWhenExpression simply add an expression like the following to only print the textfield when your group ruptures:
$V{yourGroupName_COUNT}==1
-Benjamin
I don't think that attribute is doing what you think it does. It's supposed to be used in conjunction with isPrintRepeatedValues="false" and works the following way:
"if the repeating value you have suppressed spans multiple groups, you can make it reappear at the beginning of a certain report group if you specify the name of that particular group in the printWhenGroupChanges attribute." Ultimate Guide pg. 116
I've never used the 'print when group changes' functionality, but trying it now on a new report, I see what you mean - it prints for every detail record even though the group is not changing.
Instead of using the 'print when group changes' flag, uncheck the 'print repeated values' flag, this will probably give you what you want.
Related
Looking for some advice related to data grouping and printing in Crystal Reports.
I'm working with an order confirmation form. Ideally I would create separate report pages based on a specific field value change for the 'warehouse' field. So, if any given line on an order comes from warehouse A, it prints together. Then we'd get a page break, and we'd see the form repeat for any lines coming from warehouse B.
I've inserted a new group for "warehouse" and configured the group as 'New Page Before.' But when I attempt to print I'm getting an error related to "There must be a group that matches this field". So there must be some pre-existing grouping that I'm not considering. I'm hopeful I can figure this out.
I am interested to get thoughts on overall design, and if the grouping approach I am trying to take is even the correct one.
Somewhere in your report you probably have a formula such as:
Sum({some_value}, {some_field})
where the {some_field} used to be -- but is no longer -- grouped upon.
Fix that expression to set the desired aggregation level (the 2nd argument) to a field you are actually grouping on.
My formula needs to detect when it reaches the last record in a group before the group changes. I tried using both OnLastRecord and creating a running total field (which resets on change of group) to do this. In both cases it only checks the very last record on the very last page of the report.
My ultimate goal is that I want my report to check if a number field, {#Calc} on the last record is < 0. If so output "Outsanding:" &{#Calc}*-1.
I have figured out my problem. I am now using:
{grouped field} <> next({grouped field})
which gives the value of last record for each group value.
Have you considered using the Group Footer for the group in question?
When you reach that particular footer, the active record will be the last one in the group. So any calculations you perform, or any fields you choose to print, will be based on the final record read in that group.
Note: If you're suppressing some records in the group, this might not work. In which case, you can instead use Shared Variables to store the latest valid value for Calc.
Then by the time you reach the footer, you can check to see if the variable is less than zero and display your Outstanding field based on the result.
Have been googling this for a couple of days now and tried various posted solutions, also from Stack Overflow.
I'm making a report, where there is a check on two fields to see if they have been written before. If they are, they are suppressed
psudo-code:
If {customer} and {date} as previous then suppress.
This works fine, but I need to make a count for each group. If I use the built in count function, it also counts all suppressed lines and I am running out of ways to search for a way to solve this.
I have tried to add a custom formula, that counts within each group and resets before next group, but it keeps adding to the total in all the other groups. Have tried it with both shared NumberVar and local NumberVar
Never mind. Figured it out my self.
Some of the "posted solutions" to this specific error was not fitted exactly to my needs, so tried back and forth with various solutions.
When making a Running Total Field with group, it only works when it is set to reset with each group. If you encounter this and need help to fix it, then just ask away and I will help you :)
You have to use DistinctCount instead of using regular Count.
DistinctCount ignores duplicates and only counts records with unique value.
For example, if i have data like
customer | date
---------------------
john | 01.01.2017
john | 01.01.2017
john | 02.01.2017
and i use regular count(customer,date) the result would be 3. But if i use DistinctCount(customer,date) then the result would be 2.
Hope it helps
I have a master report (using iReport 5.0.4) with a subreport that uses grouping by a field called "Group Number" (sorry, but that is the actual column name).
My report works fine when there are more than one group, but it generates each group result scrolling down the page vertically.
I would like to be able to have each group go across vertically, but when I tried using columns, it simply forces each group's data into columns, and not the entire group 1, followed by group 2 in the next column, etc.
There can be up to 8 groups, so I was hoping not to have to create 8 individual sub-subreports with a "print when" expression to show/hide them.
Can anyone tell me if this should be possible?
Thanks,
Mitch
I think making subreports is the easiest and obvious way. But if you want to make it in other way, I can only suggest to use scriptlet, and form dataset manually (Transpose it).
Another suggestion is when you generating report directly from database (i.e. passing connection into jasper) you can modify query and transpose the data (PIVOT table).
Anyway provide more info about your case. I will try to help you.
I have a multi-column Crystal 2008 report that is grouped on a date field, and I want to prevent that group from being split across the column to column boundary.
Googling it, it seems impossible - no one even has some sort of hack for faking it.
Here is an image of the issue - I would like Friday the 26th to all be in the second column.
Nothing is impossible!
While initially discouraged with the voted answer, I kept searching and found something about using a subreport for the "details". Then I used a mailing label, although this may not be necessary, but in my use I wanted each group to have identical size, this worked perfect to make sure the groups stayed together in the columns. It is a little clumsy but seems the subreport won't cross columns.
Anyway this is an old topic, but thought I would leave this here just in case someone dusts it off.
Looks like this is impossible for now.
Right click the group, select 'Change Group...', select the Options tab, check the 'Keep group together' option.
If you can determine beforehand that you want the group to print on the next column, have a blank detail line extra at the bottom of the detail lines and check the print at bottom of page and suppress it with a formula that is controlled by either a crystal variable or a database field. This is the only way I have found to cause a group to stay together. You find the print at bottom of page in the section expert, add the blank line as the last of your detail lines.