Click here to Skip to main content
14,828,891 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am use formula count value in Raw its working fine but I wanna when j is equal zero formula returned empty else returned J

How can do this?
this is my formula

What I have tried:

VB
EvaluateAfter({PayRoll_database_sp_PresentTable_Result.D01});
EvaluateAfter({PayRoll_database_sp_PresentTable_Result.D02});
EvaluateAfter({PayRoll_database_sp_PresentTable_Result.D03});

Local StringVar D01;
Local StringVar D02;
Local StringVar D03;
Local NumberVar i;
Local NumberVar j;
Local StringVar array x;

D01:={PayRoll_database_sp_PresentTable_Result.D01};
D02:={PayRoll_database_sp_PresentTable_Result.D02};
D03:={PayRoll_database_sp_PresentTable_Result.D03};

x:=[D01,D02,D03];
J:=0 ; 
for i:=1 to Count(x) do
(
    if x[i]="P" or x[i]="W"
    Then j:=j+1
);
j
Posted
Updated 29-Sep-20 10:01am
v2

1 solution

Try:
For example, you may have an existing formula on your report, @ShipDays, that calculates the number of days it took to ship an order. You can write the following If-Then-Else formula to show the words Same Day on the report if @ShipDays is zero, or to show just the contents of the @ShipDays formula if it is not zero:

VB
If {@ShipDays} = 0 Then 
    "Same Day" 
Else 
    {@ShipDays}

Refer: If-Then-Else Formulas | Crystal Reports 10: The Complete Reference[^]
   
Comments
Member 14944662 29-Sep-20 17:05pm
   
Where is this code used???
Sandeep Mewara 29-Sep-20 17:10pm
   
In the formula field where you want to display data.
Refer: https://www.universalclass.com/articles/computers/crystal-reports-working-with-formulas.htm
Member 14944662 29-Sep-20 17:21pm
   
like this









x:=[D01,D02,D03];
J:=0 ;
for i:=1 to Count(x) do
(
if x[i]="P" or x[i]="W"
Then j:=j+1
);

j

If {@ShipDays} = 0 Then
"Same Day"
Else
{@ShipDays}
Sandeep Mewara 29-Sep-20 17:28pm
   
In your formula field, you can write if code based on the fields available. @ShipDays is example. Use your field in the logic to set something when empty.
Member 14944662 29-Sep-20 17:36pm
   
i am make that

for i:=1 to Count(x) do
(
if x[i]="V" or x[i]="C" or x[i]="L"
Then j:=j+1;
);
j

If {@Vacation} = 0 Then
""
Else
{@Vacation}


but get error

the remaining text does not appear to be part of the formula
Sandeep Mewara 29-Sep-20 17:46pm
   
what is x, j? either define them or use the fields available. you cannot just use a raw code there. You need to read and learn about formula fields in crystal reports. Try with small examples and learn.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900