?
Solved

If-Then-Else statement.  If {field} = "Customer" then do these 3 if statements, If not then these other If statements.

Posted on 2006-04-05
7
Medium Priority
?
8,699 Views
Last Modified: 2008-01-09
Hello,

Here is my formula:

if {CUSTOMER} = "ABC" then
if {@datediff} < 5 then "Early" else
if {@datediff} = 0 then "On Time" else
if {@datediff} > 0 then "Late" else
if {SFC2.C2_NUM} = "DEF" then
if {@datediff} < 3 then "Early" else
if {@datediff} = 0 then "On Time" else
if {@datediff} > 0 then "Late"

I'm trying to make my formula to do diffrent calculations depending on the rules of the customer, as you can see customer ABC can be sent in 5 days early and DEF can be 3 days early.

Also all over customers will be 0 days early.

Phil.

0
Comment
Question by:slug0r
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 77

Expert Comment

by:peter57r
ID: 16382404
Hi slug0r,
Is there a question here?

Pete
0
 

Author Comment

by:slug0r
ID: 16382590
Hello Pete,

This formula i have does'nt work, it shows me when "ABC" are Late / Early or On Time but it doesn't show me the information for DEF and all the other customers.

I'll try explain diffrently here.   Ok i have customers ABC / DEF / GHI and each customer has diffrent rules ABC can be delivered 5 days early and DEF can be sent 3 days early and GHI can be sent 0 days early, i have a field that tells me how many days we have delivered early, i want a formula that says if ABC is < 5 days then show "Early" then if = 0 then "On time" then if > 0 then "Late" and then if DEF < 3 days then show "Early" then if = 0 then "On time" then if > 0 then "Late".

Phil.
0
 
LVL 16

Expert Comment

by:wykabryan
ID: 16382617
if {CUSTOMER} = "ABC"
then
(if {@datediff} < 5 then "Early" else
if {@datediff} = 0 then "On Time" else
if {@datediff} > 0 then "Late")
else if {SFC2.C2_NUM} = "DEF" then
(if {@datediff} < 3 then "Early" else
if {@datediff} = 0 then "On Time" else
if {@datediff} > 0 then "Late")


There are a couple of issues, as I see it from this formula.  It might not be working because you have a condition that can be met by two different section.  

@datediff = 3
if {@datediff} < 5 then "Early" else = True
if {@datediff} > 0 then "Late") = True

The other thing that might be throwing it off is the fact that you are switching up the columns.  This has played havac in some of my reports.

Hope this helps.
0
[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

 

Author Comment

by:slug0r
ID: 16382921
Wykabryan,

The formula above works better but now this part doesn't work -  if {@datediff} = 0 then "On Time" else.
Whats happening is it shows the < as Early and the > as Late but it doesn't show the = 0 as On time. (it show's them as early).

Phil.
0
 
LVL 16

Expert Comment

by:wykabryan
ID: 16382996
if {CUSTOMER} = "ABC"
then
(if {@datediff} = 0 then "On Time" else
if {@datediff} > 0  and {@datediff}<5 then "Early" else "Late")
else if {SFC2.C2_NUM} = "DEF" then
(If {@datediff} = 0 then "On Time" else
 if {@datediff}>0 and {@datediff}<3 then "Early" else "Late")

Now this only takes numbers that are greater than 0.  I would assume there is no negative numbers.
0
 
LVL 101

Accepted Solution

by:
mlmcc earned 1000 total points
ID: 16388498
I assume datediff is returning the difference in days
Early means the difference is negative?  Or will late mean the difference is negative?  
Remember 0 is < 5

if {CUSTOMER} = "ABC" then
if {@datediff} < -5 then "Early" else
if {@datediff} <= 0 then "On Time" else
if {@datediff} > 0 then "Late" else
if {SFC2.C2_NUM} = "DEF" then
if {@datediff} < -3 then "Early" else
if {@datediff} <= 0 then "On Time" else
if {@datediff} > 0 then "Late"

mlmcc
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 16397118
Glad i could help

mlmcc
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

850 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