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

If Formula 2

Status
Not open for further replies.
Jul 1, 2008
37
US
Hello,
I need help writing an if formula.

Basically, I have two fields. The first field is a step number. The step number indicates what is going on in the specific job. There is step 100, 130, 150, 250, 230 and so on. Then there is an actual work center which is associated with the step, A7-1, B10, B30, 705...

Right now, what is happening, is for step 100, the database is automatically drawing the estimated work center and I need the actual work center. The actual work center is on step 150.

Basically, for step 100 it will say Work center A7 (the estimated work center), but for step 150 it will say A7-1 (the actual work center)

What I need my formula to basically say/do is,

If {step number} = 100 then select {work center code} for {Step number} 150 else select the normal {work center}

{} = fields in the database.

How would I write a formula for this?

Thank you,
Ang
 
I don't think you can.

You could get the same result using a subreport, working out the correct value and then passing it to be subreport to link to the record with that value. Subreport values can be passed back using Shared Variable, but cannot be used until the next section of the main report.

Subreports are slow, but often the only solution. If you're using an SQL database and can write SQL code, you might be able to gather the data using a series of SQL commends.

[yinyang] Madawc Williams (East Anglia, UK). Using Crystal 11.5 with SQL and Windows XP [yinyang]
 
Hello Madawc,

Yes, I already used a sub report, which works, however it takes hours to run. I was just hoping there was a different way.

Thank you,
Angie
 
You can do the following. Create a formula:

//{@actualat150}:
if {table.step} = 150 then
{table.workcenter}

I'm assuming you have a group on {table.job}. Create a second formula:

//{@workcenter}:
if {table.step} = 100 then
maximum({@actualat150},{table.job}) else
{table.workcenter}

Use {@workcenter} instead of your field {table.workcenter}.

-LB
 
i think i would try to use a sql expression and a formula:

//{%Code}
(
Select "WorkCenterCode"
from "TableName"
where "TableName"."StepNumber" = '150'
)

//{@IF100}
IF {TableName.StepNumber} = "100"
then {%Code}
else {TableName.WorkCenterCode}

 
lb looks to be on the correct path but you may need to slightly alter the second formula to take into account if the job doesn't have a step 150

//{@workcenter}:
if {table.step} = 100 and maximum({@actualat150},{table.job}) <> '' then
maximum({@actualat150},{table.job}) else
{table.workcenter}

HTH

Gary Parker
MIS Data Analyst
Manchester, England
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top