Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Technical Questions
Message Icon Topic: Basic If statement with Variable Post Reply Post New Topic
Author Message
03-636
Newbie
Newbie


Joined: 26 Jan 2009
Location: United States
Online Status: Offline
Posts: 4
Quote 03-636 Replybullet Topic: Basic If statement with Variable
    Posted: 04 Feb 2009 at 6:47am
Hello,
I'm currently trying to create a report for out machine shop that will let them know the % of late and on time work orders.  The fallowing if statement is what I have come up with.

numberVar A :=0 ;
numberVar B :=0 ;
if {WOL_WorkOrderHistoryHeader.ClosedDate} <= {WOL_WorkOrderHistoryHeader.WODueDate} then A = A+1
else
if {WOL_WorkOrderHistoryHeader.ClosedDate} > {WOL_WorkOrderHistoryHeader.WODueDate} then B = B+1;
B/A

I put this in the detail line and the only output im getting back for A and B is a 0.
Im very new to crystal but have a small amount of programming background. Thanks for the help ahead of time!

IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 04 Feb 2009 at 7:28am
You can handle this using a by just using a 3 summary counts. NOt sure if you are grouping so you will have to adjust where you put the summaries if you are.
create a formula to get your ontime records:
if {WOL_WorkOrderHistoryHeader.ClosedDate} <= {WOL_WorkOrderHistoryHeader.WODueDate} then 1 else 0
Create a summary SUM of this to get the ontime total.
create a formula to get your late records:
if {WOL_WorkOrderHistoryHeader.ClosedDate} > {WOL_WorkOrderHistoryHeader.WODueDate} then 1 else 0
Create a summary SUM of this to get the ontime total.
 
Create a summary COUNT of all your records.
 
Create a formula to get your ontime percentage using the SUM of ontime % count of all.
SUM(@ontime)%COUNT(Allrecordfield)
Create a formula to get your late percentage
SUM(@ontime)%COUNT(Allrecordfield)
Place these on your report or group footer according to your set up
IP IP Logged
03-636
Newbie
Newbie


Joined: 26 Jan 2009
Location: United States
Online Status: Offline
Posts: 4
Quote 03-636 Replybullet Posted: 04 Feb 2009 at 10:14am
thanks alot for the help.  It work great!
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.031 seconds.