Flag formula field in Page Header based on results - crystal-reports

I am trying to flag a Y or N value in the page header if one or more specific values exist in the report result set. (Located in the details section)
It should check to see if "16" exists in the result set. I tried using a running total in the group footer, then setting the formula field in the header to display Y if the count is > 0. But the field only works on the page which contains the 16 in the details section. So if 16 only appears on Page 2, the Page 1 header will incorrectly say N. The field should be Y if 16 appears on any page.
SQL queries aren't possible in formula fields, so is there some way to make this work without one?

I would place this formula "Has16" in your details section and suppress it:
{Table.Field} = "16"
Then place a second formula in your Page Header:
IF SUM({#Has16}) > 0 THEN "Y" ELSE "N"
This will display correctly even on pages that don't contain a 16.

Related

Suppress value from display but still include in Group Header calculation

As shown below, I have a value that I wish to include in group header 1 but suppress from being displayed in Group Header 2.
Is this possible?
As shown above the Group header #2 SAM includes a value that is suppressed in the report, but shown in the group header #1. However, I also need to group by SAM and the grouping column is shown in the report with suppressed values.
(shown below as Q1 Target)
Can I suppress 'BUDGET SAM' from appearing on the report, but still include the underlying value that accompanies it, so I can get the sum of its values and show it in my group header #1 (as q1 targets)
To give you an idea of the underlying data:
To detail what I have already tried:
Suppress formula on Group#2 SAM when it equals 'BUDGET SAM'
Selection expert to remove 'BUDGET SAM'
Both of which resulted in Q1 target appearing with zero sums.
Edit:
My Suppression formula (which did not give me the correct results)
IF {Command.SAM} = "Budget SAM" THEN TRUE
ELSE FALSE
Go to Section Expert Click on Group Header 2 or which you want to suppressed on that window, and then click Suppress Formula button and then write the formula like below:
GroupName ({DataSetName.SAM}) = 'BUDGET SAM';
and then click OK and its done.

Document band Occupying white space when not printed

I need to print a set of information on the bottom of my document's first page (right after detail band). Since the information printed on detail is too large, the document creates a pagination to display the rest of the information, but independent of what I use (Group,ColumnFooter,PageFooter,etc) to print the information tha should be printed on the first page only, this band keeps occupying a white space on consequent pages.
You can create a dummy group that would break with every record, but only while we are on the first page.
Such group would not have a group header or footer, but would use minHeightToStartNewPage with a value that would match the taller page footer required on the first page.
The group expression would look like the following:
$V{PAGE_NUMBER} == 1 ? $V{REPORT_COUNT} : null
This dummy group would cause a page break to occur upper on the first page, leaving more space for a larger page footer.
Now, the second trick is to place content in the page footer section, but at a position having a negative Y coordinate. By doing so, you can keep the height of the page footer section small, while being able to render content above it.
This content having negative Y inside the page footer would be printed conditionally, only on the first page, using the printWhenExpression.

Hide or show image based on column values

I'm working on a report in which I need to show or hide images based on the values of a column. E.G: if the value 18 doesn't exist in the "Details" section, the image 18 must be hidden as described in the attached photo
I tried to use an array in which I inserted the values of the column I need to use. This is the supress expression I tried to use.
shared numbervar array MyArray;
MyArray:=makearray({MyTable.MyColumn});
local numbervar i;
local booleanvar result = true;
for i:=1 to ubound(MyArray)
do
if (MyArray[i] = 17) then
result := false;
result
I realize that the images aren't hidden because I'm working on the Page header and I can only access the first line of the table.
Because you're suppressing the images in the page header, you're limited to simple aggregate functions and won't be able to use variables, running totals, etc.
It's not hard but it is tedious because you'll have to create one new formula for each value.
//#CheckValue1
if {table.value}=1 then 1 else 0
//#SuppressionValue1
// If this evaluates to 'true' anywhere in your report, including the PH,
// you know value 1 does not appear in your report
maximum({#CheckValue1})=0

Fix the size of details section in crystal report

I m using crystal report in vs2010.
I m generating Tax invoice report..in that, details section size is dynamic.
i.e. depend on number of records, it changes. so if i've 10 records the report view is full page that is k ..but if i have 2 records in details sections, then whole page footer section getting stick to details page..so whole alignment is getting change
Try changing the print at bottom of page property in the select expert. That should do the trick.
1)First of all fix height of detail section by right click on detail section ->section expert->New Page Before checked->beside button of (x+2) write formula(Suppose you want 7 records in per page and further on another page -> IF Remainder (RecordNumber, 8) = 0 THEN TRUE ELSE FALSE
2)under detail section (suppose section3) is your detail section then leave report section blank with needed space and else for footer put it in page footer .. i think this will solve your problem.. mine is solved..
In my case in the New Page Before checked add:
IF Remainder (RecordNumber, 18) = 0 THEN TRUE ELSE FALSE

Crystal Reports - Hide Page Header on First Page

I have a report that needs to show a report header on page 1, and a different header on subsequent pages.
This seems simple enough; if I add pagenumber=1 and goupnumber=1 to the suppress formula for the second header, it will only be shown after the first page. However, the report is also supposed to reset the page count several times in a single group, thus leaving several pages that match those criteria.
Is there another field in Crystal reports that could have a unique value for the first page? Or is there another way I might go about solving this?
You have to specify in the Selection Expert - Suppress Formula the following formula:
PageNumber = 1
In the Supress Formula try this Formula
Drilldowngrouplevel = 1 ;
or
PageNumber=TotalPageCount
You have to specify in the Selection Expert - second header - Suppress Formula the following formula:
PageNumber <> 1