Is it possible to suppress a group header based on various conditions in details? - crystal-reports

I have report with a group 1 and group 2. For formatting purposes group 2 header and details are suppress and all information is presented in the group 2 footer. I have set up the report to suppress the group 2 footer if a certain condition is met, The means that sometimes the entire section under the group 1 header is blank and I want to suppress it.
Here is how it is set up
Group 1 - Employee
Group 2 - Client (suppressed)
Details (suppressed)
Client name field1 field 2 field 3 field 4
For fields 1-4 the are possible returns of "Draft", "Final" and null. I'm only looking for "Draft" and null values.
So how I've set up the group 2 footer is to just return the client name and a formula summing up the values of all four fields {#draft}
if {#divDraft} + {#convoDraft} + {#yearDraft} + {#rovDraft} >= 1 then "Draft"
else if {#divFinal} + {#convoFinal} + {#yearFinal} + {#rovFinal} >= 1 then "Final"
else " "
I then suppress the footer based upon {#draft} returning "final"
Is possible to suppress the group 1 header if every client in that group has either all four fields returned as null or at least one returned as draft?
I tried running a subreport and then placing that and a shared variable in the group 1 header but that didn't work right
WhilePrintingRecords;
Shared NumberVar totalSuppress;
Global NumberVar suppression;
suppression := Shared NumberVar totalSuppress;
The {#totalSuppress} formula in the shared report added the times at least one "draft" was returned with the number of times all four fields were null. I placed that in the footer of the subreport and then {#suppression} in the main report group header.
What I got was a pattern where the first group header was returned 0.00 where it had 4 results and 4.00 in the group footer. Then the next group had 4.00 in the group header where it had 1 result and 1.00 in the group footer. And the next one had 1.00 in the group header and so on.
I tried to do a formula to reset the variable with each group header. So I wrote
Global NumberVar suppression;
suppression := 0
But all that did was return 0.00's in the group header.
Any other ideas would be welcome.
RE: Tried new formula
if {sales_div.draft_pend_approv_Value} = "Draft" or {sales_div.draft_pend_approv_Value} = "Pending Approval"
or {convoSales_200.pending_approval_Value} = "Draft" or {rov_client.pend_draft_Value} = "Draft"
or {yearly_sales.draft_pend_Value} = "Draft") then 1
else if isnull({sales_div.draft_pend_approv_Value}) and
isnull({convoSales_200.pending_approval_Value}) and isnull({rov_client.pend_draft_Value})
and isnull({yearly_sales.draft_pend_Value})
then 1
else 0

If I understand correctly, you're trying to use the result of a Running Total Field to suppress a header - which won't work as the running total is only calculated in the footer.
You can try a different approach. Make a Formula Field which will go into your Details section. It should simply check if that row is the kind that you want to show, something like:
if (isnull({field1}) or isnull({field2}) or ... or {field1} = 'Draft' or {field2} = 'Draft' ...)
then 1 else 0
Then in the Group Header #1, in Section Expert, inside the Suppress formula put
sum({#check},{Employee})=0
where {#check} is that formula field and {Employee} is the field on which Group 1 is created

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 sum only last item in detail

I wish to display in the group footer the sum of the sold qty column (which is easily done) and then only the last value of the on hand qty column.
I think a variable can do this, but not sure how to do it as I'm new to Crystal and its variables.
Here is an example
Sold qty On Hand Qty
details 1 5
2 3
============================================
GF Total 3 3
============================================
details 6 10
3 7
============================================
GF Total 9 7
Put the field {yourTable.OnHandQty} in the group-footer.
This will show the last detail value and will work as long as there's no suppression on details.
Note: The "last record" is determined by the sort within the group. This means that if the sorting is changed, the wrong value will be displayed.
Yes !! You can do this using variables.
Step 1: Create a Formula Field Named as OnHand
OnHand
shared numbervar OnHand;
Onhand := (Your Table Field) + Onhand +;
Place this one in Details section and suppress it (Right Click
Formula --> Format Field --> Common --> Supress)
Step 2 : Create one more formula to display the result
PrintOnHand
shared numbervar OnHand;
OnHand;
Place this formula in Group Footer
Step 3 : Create one more formula Clear
Clear
shared numbervar OnHand;
OnHand :=0;
Place this formula in group Header and suppress it. (This is to clear the Onhand
Value for every records or group).

Crystal reports: how to conditionally suppress sections

I am having difficulty suppressing a group header if another group header is blank/suppressed.
Originally I had a layout as follows:
Group Header a - contains client details
Group Header b - contains a subreport that showed details of the incoming calls from client that were received in the last 24 hours.
If the sub report in group header b was blank (because no calls had been received in the last 24 hours), my report was still showing the client details in group header a.
I can suppress the group header b section if the subreport is blank, but cannot work out how to suppress group header a if group header b is blank/suppressed.
After reading various other discussions, I understood that if you want to suppress a section when a subreport is blank, then the subreport would need to be in a section before the section you want to suppress.
So, I changed my layout as follows:
Group Header a - contains sub report showing details of calls in last 24 hours (sub report is suppressed if blank, and group header a is suppressed if blank)
Group Header b - contains client details
Group Header c - contains same subreport showing calls received in last 24 hours
So what I now need to work out is, how do I suppress group header b and c if group header a is suppressed?!
Any help would be greatfully received.
You will need to check record count of sub report, if it is zero then suppress the group using conditional suppress formula. So basically in your group query somewhere you must have field which keeps the count of records in sub report.
Right Click on section
Section Expert
Suppress No Drill
Click x-2 formula editor
if {count} = 0 then true else false
Where {count} is the field having total records for that group
Hope this helps you!

Crystal Reports - Get First, Second and Third occurrence of linkedTable value

I have the following One-To-Many scenario:
One Record -> To -> Many Notes (of types X, Y and Z)
In the page for each Record, I need to include only the first 3 Notes of Type X in chronological order.
How do I do this? I've tried setting 3 subreports, but I can't tell the second and third subreport which notes have already been selected as part of the prior occurrences.
Just an extension to your solution.
First select only select 3 records to be retrieved from database.
Now sort either ascending or descending order in all 3 sub reports.
Now in sub report 1 suppress 2 and 3 records in the same way in second sub report suppress 1 and 3 records and in sub report 3 suppress 1 and 2 records.
You can suppress the records by placing the special field Record Number and suppress condition would be
if recordnumber = 1
then true
else false
Same way for second and third records.
{#ResetCounter} // Place this in the group/page header where you want to restart the counter
global numbervar counter := 0;
Place this in the section suppression formula
global numbervar counter;
counter := counter + 1;
counter > 3; // if true then suppress
If you have multiple sections to suppress make sure you only increment one time. So just remove the middle line in the subsequent suppression formulas.

Require multiple pages for a single bar chart in Crystal Reports 2008

I am creating a bar chart where the values are the maximum of an AVE_ZSCORE field, and this is set as "on change of" a PARTICIPANT_CODE field. On any given occasion, I could have up to 250 records in this chart and therefore I need to split the chart over a number of pages. This number of records is dynamic however, and can range between 150 and 250 records.
I have tried the solution in this thread http://www.tek-tips.com/viewthread.cfm?qid=1257385 and I've followed the instruction as best as I understood (please bear in mind that I'm quite new to Crystal Reports). I created a formula, inserted it in the details section which I then suppressed, then inserted a group on that formula, and inserted the chart in the group footer section. The formula I'm currently using (which I called "chart") to test this out on 4 records is:
WhileReadingRecords;
numbervar cnt := cnt + 1;
if cnt in 1 to 2 then 1 else
if cnt in 3 to 4 then 2
My problem is that the output of this results in 3 graphs of the following instead of 2 graphs containing 2 records each:
a group output of 0.00 which has all 4 records (B2, BB, KK, MM) in
one graph
a group output of 1.00 which has only one of the records (BB)
a group output of 2.00 which also has only one record, which is the
same record of the previous graph (BB)
If I change the formula to display as follows:
WhileReadingRecords;
numbervar cnt := cnt + 1;
if cnt in 1 to 4 then 1
Then the output becomes
a group output of 0.00 which has all 4 records in one graph (B2, BB,
KK, MM)
a group output of 1.00 which has one record (BB)
So firstly, I don't understand the formula that I'm using or how it works, and secondly I have no idea how to get this working so that I can easily specify the number of columns per chart
Unfortunately it's hard to say something without total understanding of your report layout. Some screenshot will easy things alot. As nothing yet specified I expect you have only one (mentioned) group in your report.
To achieve you goal you should render your chart as many times as different group values will be. This is how details section of group is rendered. Not footer or header. As chart can't be added to details section additional dummy group should be created. So in result there will be 2 groups:
Outer group (#1) will be based on your formula field and have no header/footer
Inner group (#2) will be used to show chart in either header or footer
Group #2 can be based on same formula as group #1 (or any other formula/field, it shouldn't matter).
Btw, instead of calculating count manually, like in your code
WhileReadingRecords; numbervar cnt := cnt + 1;
You can use Running total fields, with type of summary count on any field you want to control. Such fields are very customizable, so you'd like them.