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 sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

my "OR" statement doesnt appear to be pulling records

Status
Not open for further replies.

tkaplanusmc

Technical User
May 18, 2010
20
US
Hello CR 11 here, i'm trying to implement this formula but only the "and" statement appears to be working and i need to scan jobs in the database to find both "O" (open) or "S" (Started)operations. I'm embarrased that im getting hung up on something so miniscule but i need help. heres my formula

if Previous({Job_Operation.Status}) = "C" and {Job_Operation.Status} = "O"
or {Job_Operation.Status} = "S"
and {Job_Operation.Sequence} -1 = previous({Job_Operation.Sequence})
and {Job.Job} <> previous({Job.Job}) then 1

thank you in advance
 
What is your OR

Yu have to use () to make the two statements explicit

eg

if (
Previous({Job_Operation.Status}) = "C" and {Job_Operation.Status} = "O"
)
or
(
{Job_Operation.Status} = "S"
and {Job_Operation.Sequence} -1 = previous({Job_Operation.Sequence})
and {Job.Job} <> previous({Job.Job})
)
then 1

Also you do not have an else, ie what happens if those conditions are not met.

Ian
 
still no dice its only spotting jobs that are status "O" not "S". i tried your formula above as well as this slightly modified one and neither one worked.

if (
Previous({Job_Operation.Status}) = "C" and {Job_Operation.Status} = "O"
)
or (
Previous({Job_Operation.Status}) = "C" and {Job_Operation.Status} = "S"
and {Job_Operation.Sequence} -1 = previous({Job_Operation.Sequence})
and {Job.Job} <> previous({Job.Job})
)then 1
else 0


**it should be flagging sequence 9 "S" with a 1.00 in the first column from the right**

4 C 6/21/10 0.00 0.00
14STAGE
5 C 6/21/10 0.00 0.00
14WELDING
6 C 6/21/10 0.00 0.00
14DEBURR
7 C 6/21/10 0.00 0.00
14INSPECT
8 C 6/21/10 0.00 0.00
14SHIPPIN
9 S 6/21/10 0.00 0.00
14HARDWAR
11 S 6/21/10 0.00 0.00
14HARDWAR
12 S 6/21/10 0.00 0.00
14HARDWAR
13 S 6/21/10 0.00 0.00
14INSPECT
14 S 6/21/10 0.00 0.00
14SHIPPIN
15 O 6/21/10 0.00 0.00
 
Try another if instead of an or

if
Previous({Job_Operation.Status}) = "C" and {Job_Operation.Status} = "O" then 1
else
If Previous({Job_Operation.Status}) = "C" and {Job_Operation.Status} = "S"
and {Job_Operation.Sequence} -1 = previous({Job_Operation.Sequence})
and {Job.Job} <> previous({Job.Job})
then 1
else 0

Ian
 
I'm guessing you really meant:

if Previous({Job_Operation.Status}) = "C" and
(
{Job_Operation.Status} = "O" or
{Job_Operation.Status} = "S"
) and
{Job_Operation.Sequence} -1 = previous({Job_Operation.Sequence}) and
{Job.Job} <> previous({Job.Job}) then
1

The parens "tell" your formula what your logic is.

BUT shouldn't the last line be "=" instead of "<>"? With the <> you are requiring the job to be a different job.

-LB
 
i nailed it with a nested formula thanks any way for the help guys!

if ({Job_Operation.Status} = "S" or {Job_Operation.Status} = "O")
then
if (
Previous({Job_Operation.Status}) = "C"
and {Job_Operation.Sequence} -1 = previous({Job_Operation.Sequence}))
then 1
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top