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
Related
I am new to crystal reports.
Here is my data table "PAY_DETAILS".I need to display a "Basic Salary" field in my report.
So I need to check whether the Earn_Type is "CBS" and if it is true then display the CBS amount in the report.How to write this formula.
Amount Earn_Type
--------------------------------
6,789.00 ER006
2,300.00 ER007
7,890.00 ER009
88.00 ER003
88.00 ER004
48,850.00 CBS
8.00 ARS
I tried creating a formula field and drag it to report.But it displays nothing.Below is my formula.
numberVar salAmount ;
if({PAY_DETAILS.EARN_TYPE}="CBS") then
salAmount= {PAY_DETAILS.AMOUNT};
use := instead of equal when assigning a value
numberVar salAmount ;
if {PAY_DETAILS.EARN_TYPE} = "CBS" then
salAmount := {PAY_DETAILS.AMOUNT};
I am using Crystal Reports 2008 and cannot figure out the proper expression for suppressing fields.
In this case, say I have a pill diary.
{PILL.TYPE_ANTI_INFLAMMATORY}
{PILL.TYPE_PAIN_REDUCTION}
{#INTEGER_TYPE1}
{#INTEGER_TYPE2}
The first two elements from the data tables PILL are columns of pill types. The first one is a column of type of anti-inflammatory pills, the second pain reduction. These columns each contain unique information.
In the second two elements, is a column of integers either negative or positive. These are formula columns (date difference between two dates.)
My expression:
{PILL.TYPE_ANTI_INFLAMMATORY} = "Advil" or
{PILL.TYPE_PAIN_REDUCTION} in ["Tylenol", "Acetometaphin"] and
{#INTEGER_TYPE1} > 1 or
{#INTEGER_TYPE2} > 1
What I am trying to do is display any row in which ANTI_INFLAMMATORY is equal to Advil or PAIN_REDUCTION is equal to Tylenol or Acetometaphin while also one of the columns of integer type is greater than 1.
(
{PILL.TYPE_ANTI_INFLAMMATORY}="Advil" or
{PILL.TYPE_PAIN_REDUCTION} IN ["Tylenol","Acetometaphin"]
) and
(
{#INTEGER_TYPE1} > 1 or
{#INTEGER_TYPE2} > 1
)
IF ({PILL.TYPE_ANTI_INFLAMMATORY}="Advil" or {PILL.TYPE_PAIN_REDUCTION} IN ["Tylenol","Acetometaphin"])
AND
({#INTEGER_TYPE1} > 1 or {#INTEGER_TYPE2} > 1) THEN
FALSE ELSE TRUE
i have following data :
Name Amount
================
Amit 18000
Ajay 19500
Bharat 16100
how do i print the name with lowest amount in the report footer.
i tried the following formula
if {table.amount} = minimum({table.amount}) then
'Lowest Vendor - ' + {table.name}
above formula returns a blank value.
I need this in Crystal Reports not in RDBMS.
Take a local variable and store the value in that and use the variable in report footer.
Shared Stringvar a;
Shared Stringvar b;
a:=
if {table.amount} = minimum({table.amount}) then
'Lowest Vendor - ' + {table.name}
else '0';
if a<>'0'
then b:=a;
place this formula beside the amount column.
Create another formula and write below formula and place it in footer
Shared Stringvar b;
b
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
I've got the problem about crystal report. I've created one formula field called PAT_DEP and formula is as follow.
Local NUMBERVAR PAT_DEP_AMT := 0;
IF NextIsNull({MYOBJ.PAT_DEPOSIT}) = TRUE THEN
(
IF {MYOBJ.PAT_DEPOSIT} = PREVIOUS({MYOBJ.PAT_DEPOSIT}) THEN
(
PAT_DEP_AMT := 0;
)
ELSE
(
PAT_DEP_AMT := {MYOBJ.PAT_DEPOSIT};
);
)
ELSE
(
IF PREVIOUS({MYOBJ.PAT_DEPOSIT}) = NEXT({MYOBJ.PAT_DEPOSIT}) THEN
(
PAT_DEP_AMT := ToNumber(0);
)
ELSE
(
PAT_DEP_AMT := {MYOBJ.PAT_DEPOSIT};
);
)
Then I've created another formula field called TOT_PAT_DEP and formula is as follow like summarized above formula field.
TOTAL_PAT_DEP := SUM(#PAT_DEP)
But got crystal report error This field cannot be summarized crystal report error. Please help me how come I got this error.
Based on your explanation and formula, it looks like you have a one-to-many relationship which is causing you some difficulty. Let's take an example:
Order Table
Order #, Total, Paid
Order Items Table
Order #, Line #, Description
When you join the two tables you can no longer sum the total/paid columns because they will be multiplied by the number of order lines.
The way to overcome this is to create a group using the key. In my example you would group on Order #. You can then create a running total to sum the total/paid columns but will only evaluate on the change of your Order # group.
Does that make sense?