Solved

If ... Then Select... Else Syntax Problems

Posted on 2004-03-23
7
600 Views
Last Modified: 2008-02-26
I have a formula field that I had to change around a bit and it no longer gives me the results I want.  My old formula was comprised of this:

-------

if {JC1_JobMaster.Comment} like "*CORNER*" or {JC1_JobMaster.Comment} like "*DETACHED*" then
select {JC1_JobMaster.SortField}
       
        case "SADDLE M" : 140
        case "SUGAR" :  345
        case "SADDLEROCK" : 80
        case "SAVANNAH" : 43
        case "PARKFIELD" : 71.85

        default: 0

--------

On the report, all values for this field would show up as 0, or as one of the numbers from the case statement.  An important thing to know is that the line for default of 0, is not why 0 shows up.  Meaning, that if the condition is false, it still shows up as a 0 on the report.

Now when I changed my formula to this:

--------

if {JC_90_UDF_Job_Cost_Header.Trcorner} like "Y" then
select {JC1_JobMaster.SortField}
       
        case "SADDLE M" : 140
        case "SUGAR" :  345
        case "SADDLEROCK" : 80
        case "SAVANNAH" : 43
        case "PARKFIELD" : 71.85

        default: 0

---------

I no longer get a 0 showing up when the if statement is false.  I just get a blank field, and I need it to be 0.  I know it should probably be something like this:

If (condition) then
select

...

else
0

But I can't figure out the syntax.

Any help would be appreciated, and I'm curious to know if anyone can explain why the 0 values stopped showing up.

Thanks!
0
Comment
Question by:Mourdekai
7 Comments
 
LVL 77

Expert Comment

by:peter57r
ID: 10659586
Hello Mourdekai,

it shouldbe something like this:
 
 If (condition) then
 (
select
 
 ...
 )
 else
 0



Pete
0
 
LVL 8

Author Comment

by:Mourdekai
ID: 10659621
Pete,

if {JC_90_UDF_Job_Cost_Header.Trcorner} like "Y" then
(select {JC1_JobMaster.SortField}
       
        case "SADDLE M" : 270
        case "SUGAR" :  215
        case "SADDLEROCK" : 280
        case "SAVANNAH" : 430
        case "PARKFIELD" : 701.85

        default: 0;)
else
0


Does NOT work, any other suggestions?
0
 
LVL 8

Author Comment

by:Mourdekai
ID: 10659730
I figured it out, this is what I needed before my if

if isnull({JC_90_UDF_Job_Cost_Header.Trcorner}) then 0
else
if {JC_90_UDF_Job_Cost_Header.Trcorner} like "Y" then
select {JC1_JobMaster.SortField}
...
...

0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 28

Expert Comment

by:bdreed35
ID: 10659778
Try this:

if instr({JC_90_UDF_Job_Cost_Header.Trcorner},"Y")>0 then
(select {JC1_JobMaster.SortField}
       
        case "SADDLE M" : 270
        case "SUGAR" :  215
        case "SADDLEROCK" : 280
        case "SAVANNAH" : 430
        case "PARKFIELD" : 701.85

        default: 0;)
else
0
0
 
LVL 8

Author Comment

by:Mourdekai
ID: 10659876
bdreed35, thanks for trying but that doesn't work either.  See my above post for the solution I found.
0
 

Accepted Solution

by:
PashaMod earned 0 total points
ID: 10694322
Closed, 172 points refunded.
PashaMod
Community Support Moderator
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now