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};
Related
I want to suppress a group if a field does not change within that group. Here is a screenshot of my example data (the two red-boxed fields showing the groups that have the unchanging field):
As you can see the two groups, reservation_number 10002 and 10014, should be suppressed as their amount field does not change.
Ideally the above screenshot should become this:
Please note that there can be more than two amount rows in a group.
Follow below process
Create a formula #Initialize and write below code and place in group header
Shared numbervar counter;
counter:=0
Create one more formula count and write below code and place in detail where you have data rows
Shared numbervar counter;
if PreviousIsNull(amount)
then counter:=counter+0
else if previous(amount) = amount
then counter:=counter+0
else if next(amount) = amount
then counter:=counter+0
else counter:=counter+1
Create one more formula result and place in groupfooter
Shared numbervar counter;
Shared Numbervar counter1:=0;
counter1:=counter;
counter
Go to section expert and supress and write below condition:
EvaluateAfter({result}) ;
Shared numbervar counter;
if counter = 0
then
true
else false
Use below formula for supress of header:
EvaluateAfter({result});
Shared Numbervar counter1;
if counter1 = 0
then
true
else false
Let me know if this works else will suggest other way
I have a variable dItemDesc defined in the Group Footer:
whilereadingrecords;
stringvar DispItemDesc;
DispItemDesc := DispItemDesc + "> " + {Command.ItemDesc}
The display for the first record is correct, but following records just continue to concatenate the string. Where / how would I reset the variable to blank?
Create another formula as a reset. Place it at the stage you'd like it to clear out. (Presumably one section below the current Group Footer, or in the Group Header.)
whilereadingrecords;
stringvar DispItemDesc;
DispItemDesc := ""
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 the following problem:
-- I have one database table with the following structure : < Age, Gender , Wage., ..>
-- I have one Crystal Reports report with two subsreports , each displaying a graph of wage per age , one for records that have male gender the other for female gender.
I would like to suppress one subreport if the table has no records with gender value "male" or "female".
Thanks,
Vali
Create SQL Expressions which count occurences of male and female values in the gender column. For example:
(select count(male) from dbtable where gender = 'male')
Then suppress the subreport you want simply by a suppress formula {%SQL_expression} = 0
A good presenatation about SQL Expressions is here: https://www.box.com/shared/i2jk8yohku
Alternatively you can use a formula which reads the fields while reading them from database using WhileReadingRecords and a shared BooleanVar.
WhileReadingRecords;
Shared BooleanVar isMale;
isMale := False;
if (dbTable.Gender = 'male') then
isMale := True;
isMale;
Then use the shared BooleanVar to suppres the sbreport.
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