how to set conditions for total or cell in cross tab in fastreport for visible or width=0 - crosstab

I have a cross tab in Fast Report 5.
I want to set a condition for column header or cells that cells visible is off.
How to set conditions which are 'visible is off' for cells?

You may set column width to 0 in the cross-tab OnCalcWidth event
procedure Cross1OnCalcWidth(ColumnIndex: Integer; ColumnValues: Variant; var Width: Extended);
begin
if ColumnValues[0] = '2000' then Width := 0;
end;

Related

Crystal Report Cross Tab Calculated Member as text

I'vre created a cross tab report with 2 calculated Member to be able to have the difference between 2 column and the percentage of this difference in CR 2011. What I want to achieve is to create a new column that will display a test depending on the difference value.
Here is a example:
Col1 Col2 Difference Percentage Action
200 0 -200 100 DROPPED
100 100 0 0
0 300 300 100 ADDED
How can create this action column. Calculated member only want some amount value so I cannot output a text in the formula.
Thanks in advance for your help
I finally found the solution.
I can use the Display string formula in the Format Field properties (Common Tab). Here I just check the column and return the string I want otherwise I just format the number.
IF GetColumnGroupIndexOf(CurrentColumnIndex) = 1
AND CurrentColumnIndex =4 THEN
IF GridValueAt(CurrentRowIndex, CurrentColumnIndex,CurrentSummaryIndex) =2 THEN "DROPPED"
ELSE "ADDED"
ELSE
ToText( GridValueAt(CurrentRowIndex, CurrentColumnIndex,CurrentSummaryIndex),2,",")

Crystal Reports: multi-value parameter to filter on substring value

I have a Crystal Reports 2008 file with a string parameter that accepts multiple values. I need to use this in the record selection. I know generally you can do something like
{MyTable.MyField} In Join( {?MyParam}, "," )
but I need users to enter values that may appear in a much longer field value, i.e., by substring. I tried
NumberVar index;
For index := 1 To UBound( {?MyParam} ) Do (
{?MyParam}[index] In {MyTable.MyField}
)
and while it doesn't throw an error, it doesn't seem to have any effect on record selection (that is, the report displays the same number of records regardless).
To be more specific, say MyTable has three records, and MyField contains the text Red Blue Green, Green Yellow Purple and Red Yellow Orange respectively. With the parameter, the user should be able to type the values red and blue in order to filter down to the first and third records.
Create a custom formula to compare two arrays for over-lapping values:
//Array_Overlap
Function (Stringvar Array a0, Stringvar Array a1)
Local Numbervar i;
Local Numbervar j;
Local Booleanvar found:=false;
For i := 1 To Ubound(a0) Do (
For j := 1 To Ubound(a1) Do (
If a0[i]=a1[j] Then (
found:=true;
Exit For;
)
)
);
found;
Reference it in your record-selection formula (RSF):
// space delimited
AND Array_Overlap( Split({MyTable.MyField}, " "), {?MyParam} ) = TRUE

For each crosstab column, highlight maximum value

I'm trying to highlight the maximum value in a Crystal Reports crosstab column, per column, i.e. show the best performing salesman in each month.
It seems like a fairly basic requirement, but I can't figure it out! The Highlighting Expert would seem to be the obvious answer, but it only works if you have defined criteria (e.g. Gross Sales > 120,000), and I'm not interested in highlighting the Totals at the end of the columns/rows....I just want the highest value row per column.
This is much more difficult than it needs to be...
Add this text to the summary field's "Tool Tip Text" conditional-formatting formula:
// this assumes that there is a Total column and that it is the left-most column.
Numbervar max:=0;
local Numbervar col;
// exclude (left-most) total column
for col := 1 to GetNumColumns-1 do (
local numbervar value := GridValueAt (CurrentRowIndex, col, CurrentSummaryIndex);
if value > max then max := value;
);
ToText(max,"#");
Then add this text to the same field's "Style" conditional-formatting formula:
Numbervar max;
If GridValueAt (CurrentRowIndex, CurrentColumnIndex, 0) = max Then
crBold
Else
crRegular

SELECT and SET with ROWCOUNT

I have a SP with which I fetch a defined amount of rows. How can I change the value of a column in the fetched rows? Such as 'has been fetched' = 1.
Any advice?
EDIT:
The SP looks something like this
SET ROWCOUNT #numberOfRows
SELECT * FROM tableA where notSent = 1
I would like to change the 'notSent' colum for all the rows that i fetch. Is this possible?
1) Don't use Select * in a stored procedure - always specifically list the fields required as shown below - replace field1,2,3 etc with the actual fields you want returned.
OK - Modified answer:
2) Set a flag on the columns you want to select and update with a value that will not be otherwise programmatically set - e.g. -1 - Then select these records, then update them to set the final value required. Doing it this way will avoid the possibility that you will update a different set of records to those selected, due to inserts occurring half-way through the stored procedure's execution. You could also avoid this by use of locks, but the way below is going to be far healthier.
UPDATE Table set notSent = -1 WHERE notSent = 0
SELECT ... from Table where notSent = -1
UPDATE Table set notSent = 1 where notSent = -1

Crystal Report with multiple datasources, one is empty

I have a Crystal report with a table as a datasource and I want to include another table with details for the report footer.
I have two data sources in the report which are not linked, but when the selection criteria returns no rows from the main table, the results from the non-empty non-linked source are also empty.
I suspect it's doing a cross join between the two datasources, so if one is empty, that joined with another is also empty. The problem is I need my rows from the non-empty table to show in the report footer section, and they're getting suppressed by the other, empty datasource.
How can I get rows from an independent table to show in the report footer when the selection criteria and their parameter choices return an empty result set in the main table?
Thanks for your help,
-Beth
Also, I tried using a command as a datasource with sql like this:
select * from waitlist
union all
select distinct null as reportID, null as ..., lastupdated
from waitlist
but it still returns null for lastupdated and suppresses the subreport in the report footer.
I ended up setting my report datasource to a view which unioned another row to the table. I also needed to change my selection criteria so it allows this row to pass through.
Here's my datasource:
CREATE VIEW [dbo].[vw_rpt_waitlist] AS
select * from waitlist
union all
select distinct
reportID,
null as (fields...),
lastupdated,
'reserved' as countyName
from
waitlist
and here's my record selection formula:
({vw_rpt_waitlist.countyName} = {?County} or
{vw_rpt_waitlist.countyName} = "reserved") and
{vw_rpt_waitlist.reportID} = 14
I'm also suppressing the detail section if there were real rows returned:
formula = {vw_rpt_waitlist.countyName} = "reserved"
and to get the parameterized county name they selected in the page header of the report, I'm using:
dim t as string
dim c as string
if {vw_rpt_waitlist.countyName}="reserved" then
c = {?County}(1)
else
c = {vw_rpt_waitlist.countyName}
end if
t = "Waitlist by " + {#serviceTitle} + " and Waiver Need Index as of "
+ cstr({vw_rpt_waitlist.lastUpdated},"MM/dd/yyyy")
formula = t
Since the 'reserved' county always comes through, the subreports are not suppressed.