Crystal Reports 2008: Suppress Group Header when details are suppressed - crystal-reports

I have a report that currently displays data in the following format:
GROUP HEADER
January Meter Number Name Class Facility ...
...
December MeterNumber Name Class Facility ...
GROUP HEADER
January Meter Number Name Class Facility ...
...
December MeterNumber Name Class Facility ...
I have a conditional suppression formula on the details lines that will suppress a record if one of the fields values is higher than a specific value. Everything works great if I suppress the Group Header line, but I just get a long list of the records
that are not supposed to be suppressed. I would like to leave the Group Header visible so the report is easier to read. The problem is that when I add the conditional suppression formula to the Group Header line, it only looks at the first record in the group. If that record is suppressed, then so is the Group Header, but there may be 3 months worth of records that are not supposed to be suppressed so I would still like the Group Header to display. Instead what I get is the following:
March 10003 Name Class Facility ... //Notice no Group Header
April 10003 Name Class Facility ...
December 10003 Name Class Facility ...
Group Header
January 10004 Name Class Facility ...
March 10004 Name Class Facility ...
February 10005 Name Class Facility ... //Notice no Group Header
March 10005 Name Class Facility ...
Due to the January month being suppressed for meter number 10003 and 10005, the Group Header is also suppressed. I tried placing the Group Header on the details line and that works in the since that it prints the Group Header on every line but then I format that field and suppress duplicates and it does the same thing all over again. It only displays those Group Headers where the January record is not suppressed. This wouldn't be such a big deal but I am dealing with 1000+ records after the suppression.
I have searched for two days for a solution to no avail. Is there any way to look at all records in a group instead of just the first record when it comes to suppressing?
EDIT: For those questions as to why I need to suppress the Group Header when all of the details in that meter are already suppressed it's because if I don't then I get the following:
10003
10004
January 10004 Name Class Facility ...
March 10004 Name Class Facility ...
10005
February 10005 Name Class Facility ...
March 10005 Name Class Facility ...
10006
10007
10008...
In other words, I will get a few pages of just group headers before I see one with actual details.

For the sake of illustration, I'm going to assume that the logic to suppress your Details section is contained in the formula {#SuppressDetails?}. Now, create a new formula that outputs a 1 when the section is suppressed and a 0 otherwise:
if {#SuppressDetails?} then 1 else 0
Place this new formula in the Details section and suppress it. Now, create your Group Header suppression formula such that it compares the number of suppressed Details sections to the total number of records in that group (that is, the {table.MeterNumber} group):
count({#SuppressDetails?},{table.MeterNumber}) = sum({SuppressDetails?},{table.MeterNumber})

I actually found my own way to do this which I now prefer. It's very similar to the one #ryan posted.
I first created a formula field that returns a 1 when the condition is met and I set the condition to the same condition for the detail level suppression. I put that field on the detail level and I suppressed it.
I then created a summary field that sums up that field over the group. And put that field in the group summary and suppressed that too. I then added a suppression rule to the group that said if that summary field is less than 1 then suppress the group summary too.
Viola

Related

how to suppress group header 1 if group header 2 is not showing anything

please help this noob on suppressing a group header 1 if group footer 2 is not displaying anything might be because there are no records to display, or all records are suppressed. I have a suppressed condition on group footer 2
IACode Group header #1 [Description]
ICode Group header #2
Details | itemcode | date | aantal | qty (supressed)
ICode Group footer #2| itemcode | date | (SUM)aantal | SUM(qty)
IACode Group footer *1
sample result
ABC Company (no data)
Helios Corporation
xx1001 09/10/2022 200 100
xy2091 09/22/2022 125 099
Super Tech Company
yy2222 01/10/2021 100 234 (suppressed as per suppress condition)
it should only show
Helios Corporation
xx1001 09/10/2022 200 100
xy2091 09/22/2022 125 099
current suppression condition # x+2 of Group Footer #2
ISNULL({qty}) OR {#datum} > 90 OR {aantal} = 0 (this is the only formula for the suppression).
and for the formula datum is date('9/1/2022') - {table.date}.
You have to evaluate the fields within Group Header 2 while printing Group Header 1.
So imagine a Crystal Report for inventory items. If I group my inventory items first on ITEMNO, and then on REVISION, I will have a report with ITEMNO in Group Header 1, and REVISION in Group Header 2. Then the details sections can contain other fields such as ONHAND_QTY, PRICE, STD_COST, ect...
Not every item will have a REVISION, so there will be some NULL values in this field. If I wanted to suppress Group Header 1 when Group Header 2 contains no data, its easily done when the fields within Group Header 2 all contain NULL values. To do this I simply use the following formula in the Suppress property of the Group Header 1 section.
ISNULL(GroupName ({ARINVT.REVISION}))
If the REVISION field is NULL, this formula returns TRUE and suppresses Group Header 1. If you have multiple fields in Group Header 2, you will need to test each field for NULL values. Now the formula becomes:
ISNULL(GroupName ({ARINVT.REVISION})) & ISNULL(OTHER_FIELD_1) & ISNULL(OTHER_FIELD_2)...
Now the tricky part comes into play when you need to suppress Group Header 1 because Group Header 2's fields have all been suppressed and do not contain NULL values. In order to satisfy this requirement, you will need to create an aggregate of all of the formulas that suppress the fields in Group Header 2. And then use that same logic to suppress Group Header 1. Its hard to provide much of an example of this without full knowledge of how you are suppressing fields within Group Header 2. I'm willing to give it a try though if you can share all of the formulas used to suppress the fields in Group Header 2.
Now you need to combine the formula for supressing Group Header 1 when all the fields in Group Header 2 are NULL with the aggregate of the formulas used to suppress fields within Group Header 2. This would roughly look like this:
ISNULL(GroupName ({ARINVT.REVISION})) or [aggregate formula goes here]
This formula should then return a value of TRUE if all of the fields are NULL or if all of the fields are suppressed within Group Header 2.

crystal reports Summarising field in group header has duplicated value

I am trying to summarise (sum) a field in a group header and the value is being multiplied by the number of details lines within the group.
The structure of my data is the following tables-
Branch
Job
Invoice
InvoiceLineItem
and my report groups follow the same pattern, with the invoice line item being the detail line
So I can include a summary of any of the InvoiceLineItem fields in the group header and this works as expected.
What I want is to include a summary of a field from the invoice table, for instance "NumberofDaystoDeliver" in all the group headers. So in the Invoice group header, its simple, i just put the Invoice.NumberofDaystoDeliver field there.
But when I create a summary in the Job and Branch groups the Invoice.NumberofDaystoDeliver field is summed for each detail line which can be a varying number.
I know I can use Running Totals in the footer but is there any way to do this in the headers?
Thanks

Crystal Reports: How to suppress all records in group if ONE based off the value of 1 field

I have a report which lists all employee timesheets (grouped). Each employee will have a record for each day (5 records in total) per group. I want to suppress ALL records for a employee if ANY of the 5 records has a value in a particular field (called "uniqueAttachID").
Basically, if the "uniqueAttachId" is blank, it tells me that the record does not have an attachment and I want to see all employees where this is the case. The attachment can be added to ANY of the 5 records therefore, if ANY of the records HAS data is this field, then I want the whole section of the group suppressed.
You can use below trick to achieve your requirement,
1] create a summary on uniqueattachedID across the group. This summary will give you sum of uniqueattachedID column. Suppress this summary.
2] Now go to the Section Expert of the group. Write formula for Suppress.
3] In formula you will write
if summary column (select this from reports field) > 0 then true
else false
I hope this helps!
If you want to suppress ALL records (Group and Detail), you will have to go into Section Expert, and in the suppress formula for each section of your report that you want to suppress, you enter
uniqueAttachID <> ""
That will suppress each section if uniqueAttachID has a value. You may need to adjust the formula if uniqueAttachID is a numeric field.

Crystal Reports XI - Suppress group header based on suppression status of sub-groups

I have a rather simple problem that I haven't managed to workout for myself despite many hours of searching the web.
I have a report containing timestamped data from a few thousand devices (loggers), to present the data in a sensible manner, I set up two groups in the report; Loggers and Timestamp so the data first grouped by logger id and then by timestamp which is working fine
Group 1 Logger 1
Group 2 Timestamp 01/08/2012
Data...
Data...
Data...
Group 2 Timestamp 02/08/2012
Data...
Data...
Group 1 Logger 2
Group 2 Timestamp 01/08/2012
Data...
Data...
Data...
Now the data (detail) fields are hidden from the user and I only want to display the header for group-2 if there are 4 or more records in each group-2. To achieve this I have used the following suppression formula on group-2
Count ({GMAC_spDg2Report;1.tTimeStamp}, {GMAC_spDg2Report;1.tTimeStamp}, "daily") < 4
The trick is that there are certain level 1 groups where all group-2 headers are suppressed and where this is the case, I want to hide the group-1 header as well.
Using the same suppression formula as group-2 in group 1 did not yield the desired result. I have also tried to use a running total (called {#Count Unsupressed Days}) in the group-1 footer with a distinct count and the formula below being reset on each group-1
Count ({GMAC_spDg2Report;1.strLogger}, {GMAC_spDg2Report;1.tTimeStamp}, "daily") > 4
The running total works perfectly, returning a 1 in group-1 footer if the group has sub groups that are not suppressed and 0 if all group-2 headers are suppressed.
So here is the CHALLENGE, I cannot seem to apply a suppression rule in the header of group-1 using the output from the running total.
To demonstrate the problem I created a formula field containing only the output from the running total and placed this in the group-1 header.
The results are confusing to say the least... the formula field does not show the same value as the running total and hence the suppression rule is not working.
I hope this makes some kind of sense... I feel like I have tried everything
I don't have a definite solution, but using a formula field starting with
WhilePrintingRecords;
...
the formula will be processed after all records are read, and therefore you will be able to use it in section headers with correct result.
Now there is the problem of finding a formula logic that will be of use for you, but perhaps this first step can help you in the right direction.
I had a similar problem once. As I remember, the trick was to check Suppress blank section in every detail section and checking some similar sounding option Suppress blank group (?) in group header section.
Sorry I can't give you the exact name, it's long ago and I used the German version. I know it's possible without formulas, though.
I take it you don't use sub reports. If you do, note that the trick only works if the sub report has the option Suppress empty report (?) checked along with what I wrote above.

Groups being printed twice after page break

I have made a report that shows transactions in a certain time period for certain products.
To simplify it; its based off 3 tables: Transaction, Product and Customer. Transaction joins to Product and Customer by keys ProductID and CustomerID respectively. The product can be used by several customers though, so there is no join between customer and product.
The report is structured as below:
Report Header:
-Group Header 1 - CustomerID (prints name, id etc)
--Group Header 2a - Product Code (prints name, description..)
--Group Header 2b - sub report GetOpeningBalance
---Group Header 3 - Transaction Date
----Details (nothing printed)
---Group Footer 3 - Prints transaction date, details, new balance
--Group Footer 2 - Prints Product closing balance (opening - transactions).
-Group Footer 1 - Prints nothing.
Report Footer - prints nothing.
The sub report GetOpeningBalance calls a stored prodedure and returns a number in a shared variable corresponding to the opening balance. This is then incremented/decremented by each transaction and the closing balance is displayed at the end.
Now the selection formula is based on: Customer, Product and Date Range (to/from). Customer and Product can be discrete, range or discrete + range values.
This worked fine; it showed product transactions which occured in the range given and displayed numbers. The customer however wanted it to show all products; even if no transactions had happened in that time period. For example they had stock; but there were no intakes/outtakes so the opening and closing balance are equal.
So to solve this; I removed the date range parameter in the selection criteria (so it returns all transactions for the product) and have then supressed any detail lines that fall outside of the wanted date range. I have modified the running total formulas accordingly so they only include the "shown" transactions.
Now I am experiencing strange behaviour. Complete groups can be duplicated on the next page.. Say products 1-9 are printed on page 1, you would expect page 2 to start with product 10 and so on. However products 1-9 are printed; but then products 8 AND 9 are printed again at the start of page two . It prints the full section including the correct totals.
This behaviour is not consistent; it wont do it on every page or for every date range/product selection.
I have attempted ticking/unticking keep together in the Section Expert and the Group Expert. I have also tried removing some extra groups and details to try narrow it down to no avail.
Are there any options or settings that may be causing these groups to be reprinted?
I would usually use a subreport for the details section in these kind of problems; however because there is no direct join between product and customer it makes it impossible.
I had some free time to play with this today.
I found that switching the Group Header 2a with 2b; so that the subreport is before the product details header will stop this behaviour happening.
Now to test, test, test!