Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

End Formula Calculation When Condition Is Met

Status
Not open for further replies.

dazum

Technical User
Apr 6, 2011
57
US
I am using CR XI
In the below formula, I would like the formula to stop the calculation after the stringvar PassFail result is either "Pass" or "Fail" and continue if the result equals "AIT".

stringvar PassFail;
if CDATE({@Activity Date}) <= DateAdd("d",1,CDATE({INTAKE.DECISION_DATE}))
and {ACTIVITY_LOG_PARTICIPANT.CONTACT_STATUS_CODE} = "COMPLETED"
then
PassFail := "Pass"
else
if CDATE({@Activity Date}) <= DateAdd("d",1,CDATE({INTAKE.DECISION_DATE}))
and {ACTIVITY_LOG_PARTICIPANT.CONTACT_STATUS_CODE} = "ATTEMPTED"
then
PassFail := "AIT"
else
if CDATE({@Activity Date}) > DateAdd("d",1,CDATE({INTAKE.DECISION_DATE}))
and {ACTIVITY_LOG_PARTICIPANT.CONTACT_STATUS_CODE} in ["ATTEMPTED","COMPLETED"]
then
PassFail := "Fail";

 
Just change it around, if..then..else stop as soonas it encounters a true condition

stringvar PassFail;
if CDATE({@Activity Date}) <= DateAdd("d",1,CDATE({INTAKE.DECISION_DATE}))
and {ACTIVITY_LOG_PARTICIPANT.CONTACT_STATUS_CODE} = "COMPLETED"
then
PassFail := "Pass"
else
if CDATE({@Activity Date}) > DateAdd("d",1,CDATE({INTAKE.DECISION_DATE}))
and {ACTIVITY_LOG_PARTICIPANT.CONTACT_STATUS_CODE} in ["ATTEMPTED","COMPLETED"]
then
PassFail := "Fail"
else
if CDATE({@Activity Date}) <= DateAdd("d",1,CDATE({INTAKE.DECISION_DATE}))
and {ACTIVITY_LOG_PARTICIPANT.CONTACT_STATUS_CODE} = "ATTEMPTED"
then
PassFail := "AIT";

Ian
 
Ian
I tried rearranging the order of the formula but it did not present the data the way I need it. Below is what I am trying to accomplish with the formula;
Current Data Display;
Decision Date ---- Activity Date ---- Status Code ---- @Pass - Fail
1-22-13 -------- 1-23-13 --------- COMPLETED ------ Pass
1-22-13 -------- 2-20-13 --------- COMPLETED ------ Fail
1-22-13 -------- 2-21-13 --------- COMPLETED ------ Fail
What I'd like the Data to Display;
Decision Date ---- Activity Date ---- Status Code ---- @Pass - Fail
1-22-13 -------- 1-23-13 --------- COMPLETED ------ Pass
1-22-13 -------- 2-20-13 --------- COMPLETED ------
1-22-13 -------- 2-21-13 --------- COMPLETED ------

after the first time the @Pass - Fail formula results in Pass or Fail I want the formula to end like above.
 
I assume you data is grouped in some way.

In group header add formula

@reset
whileprintingrecords;
global stringvar PassFail:=Fail;


not totally sure of the logic required but Change your formula to something like

whileprintingrecords;

global stringvar PassFail;

if CDATE({@Activity Date}) <= DateAdd("d",1,CDATE({INTAKE.DECISION_DATE}))
and {ACTIVITY_LOG_PARTICIPANT.CONTACT_STATUS_CODE} = "COMPLETED"
then
PassFail := "Pass"
else
If PassFail = "Fail" and
CDATE({@Activity Date}) > DateAdd("d",1,CDATE({INTAKE.DECISION_DATE}))
and {ACTIVITY_LOG_PARTICIPANT.CONTACT_STATUS_CODE} in ["ATTEMPTED","COMPLETED"]
then
PassFail := "Fail"
else
if PassFail := "Pass" or PassFail := ""
then PassFail := ""
else
if CDATE({@Activity Date}) <= DateAdd("d",1,CDATE({INTAKE.DECISION_DATE}))
and {ACTIVITY_LOG_PARTICIPANT.CONTACT_STATUS_CODE} = "ATTEMPTED"
then
PassFail := "AIT";

Hope this gives you some pointers

Ian

 
Ian
I do have a group for the @Activity Date field.
I tried incorporating the changes you suggested, but I errors out with "A Boolean is Required Here" at the line in formula that reads if PassFail := "Pass" or PassFail := ""
I have been trying a few things, but can't get around that error in the formula.
 
try removing the ":"s from the offending line.

if PassFail = "Pass" or PassFail = ""
then PassFail :=
 
fisheromacse, Ian
I edited the formula and it no longer errors out. I ran the report and it did not change the results of the data, it is still displaying as shown below;

Decision Date ---- Activity Date ---- Status Code ---- @Pass - Fail
1-22-13 -------- 1-23-13 --------- COMPLETED ------ Pass
1-22-13 -------- 2-20-13 --------- COMPLETED ------ Fail
1-22-13 -------- 2-21-13 --------- COMPLETED ------ Fail

I need ithe formula to stop computing after a record is either Pass or Fail and the following records are null. I've tried changed the order of the conditions, but that didn't help.
Any suggestions would be helpful!
 
I think you are trying to do too much with one formula, create 3 formulae for Pass, fail and ait.

Which each return a variable in a similar way. You will need a reset formula in the group or report header as appropriate

Then conditionally suppress depending on the values of the 3 variables

Ian
 
Forgot to mention you will lay the 3 formula on top of each other and then let suppression rules determine if visible or not

Ian
 
Ian,
I have to try a different approach, I don't think the what I was trying was going to work.
I was going to try something different, below is the data.
Is it possible to give a value to the first instance @Pass-Fail <> @shared AIT?

@Record # --- @Activity Date --- @Pass-Fail ----- @shared AIT ---@Counter
1 --------------- 1-29-13 -------------- AIT ------------- AIT ------------------- 0
2 --------------- 1-30-13 -------------- Pass ------------ AIT ------------------- 1
3 --------------- 2-26-13 -------------- Fail ------------ AIT ------------------ 0
4 --------------- 3-6-13 -------------- Fail ------------ AIT ------------------- 0
5 --------------- 3-6-13 -------------- Pass ------------ AIT ------------------- 0
6 --------------- 3-18-13 -------------- Fail ------------ AIT ------------------- 0
Do you think it is feasable to create a Counter formula to accomplish this?
I am grouping by @Activity Date
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top