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!

How Do I Add an If Then Statement to A Report?

Status
Not open for further replies.

kc27

Technical User
Sep 10, 2008
171
US
I am composing a report in Crystal Reports 9. The report's purpose is to create a list of projects and their corresponding due dates. However, there are two main types of projects, and depending on the type of project, the due dates will be found in one of two tables. If I run reports for the project types separately, going to the respective due date tables, the reports return data. If I attempt to put both project types in the same report, I get no results. I am thinking that an if-then statement will allow the report to work correctly. I created the one shown below

If {ad_info.media_cd} = "ROP" Then
{vrsn_prdctn_schdl.job_step_due_dt}
Else
If {ad_info.media_cd} <> "ROP" Then
{ad_prdctn_schdl.job_step_due_dt}

What I am not well versed on is implementing this type of statement. If I create a formula in the Formula Workshop, how do I implement it into the report?

Thanks in advance for any ideas on this.







 
Your statement is pretty much there. You create a new formula in the workshop, which creates a "field" in the field explorer. Just drag that formula field onto the report where needed.
 
Thanks for the reply. I've never created a function before. Please elaborate on what you mean by dragging it over to where needed?
 
KC -

When you create the formula in the workshop, and hit save/close to exit the workshop it is going to create the formula as a field in the field explorer (most commonly found on the right hand side of the screen). To use the formula in the report, you can drag and drop the formula field from the field explorer into the report where you need it to be. I'm assuming in this case, the detail level.

 
I think you have a linking problem. You should use left joins FROM the ad_info table TO each of the other two tables.

-LB
 
jlopeman - Thanks for the clarification. I did add the formula to the details section. When I did that, it added a column to the report. The purpose of the formula is to work in the background, not appear on the report. Is there another step I need to perform?

tbass - Thanks for your suggestion. I did as you outlined and changed the links to left outer joins. It did not fix the problem. Is your suggestion dependent on having a working formula on the report?

 
If you do not want to see the formula, you can always suppress it. It is a pretty common practice.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top