Peter Bloeme Posted November 17, 2005 Posted November 17, 2005 I've been successful in creating a calcuation field with a basic "If Statement." If this, else that. However, I am now trying to create a calculation field that has several criteria. If this If this If this Else this However, if I code: If... Else If... Else If... Else... As I can in ScriptMaker, I get an error message that the program doesn't recognize the "Else If." So I guess I'm asking if you can have repeated "If" statements in a field definition and, if so, how? TIA
SlimJim Posted November 17, 2005 Posted November 17, 2005 In a calculation you need to nest the ifs (or use a Case statement). For example If(test1;result1;If(test2;Result2;If(test3;Result3;Default))) or as a Case statement Case( test1;Result1; test2; Result2; test3;Result3; Default)
SlimJim Posted November 17, 2005 Posted November 17, 2005 Looking at the posting times I reckon that's a draw.
LaRetta Posted November 18, 2005 Posted November 18, 2005 If(test1;result1;If(test2;Result2;If(test3;Re sult3;Default))) Ummm, that is what AND is for If this AND this AND this ... I dislike pseudo examples because they never make sense. If you give us your specific need, we can help you with real logic. Otherwise, we're all just guessing here ... LaRetta
SlimJim Posted November 18, 2005 Posted November 18, 2005 If(test1;result1;If(test2;Result2;If(test3;Re sult3;Default))) Ummm, that is what AND is for If this AND this AND this ... I don't think this is a simple AND. In words: if test1 is true then result1. If test1 is false and test2 is true then result2 If text1 is false and test2 is false and test3 is true then result3 If test1 is false and test2 is false and test3 is false then default
Peter Bloeme Posted November 18, 2005 Author Posted November 18, 2005 (edited) Thanks everyone! All those replies look great and I'm sure I can get my field to work correctly now...I'll let you know. In the meantime, if both "If" and "Case" statements will work, why choose one over the other in a formula? I've never been able to understand that. TIA Edited November 18, 2005 by Guest
Søren Dyhr Posted November 18, 2005 Posted November 18, 2005 choose one over the other in a formula? Iffing is somewhat tighter with only 2 results, while Case( can be almost limitless, in the stacking of conditions. The readability is the main factor when choosing. It's a matter of developers habits I do hardly ever use iffing!!! --sd
Peter Bloeme Posted November 18, 2005 Author Posted November 18, 2005 OK, wanted to let everyone know I used the "Case" statement and it worked beautifully! Although I suspect that the "If" statement would have worked equally well. Sometimes the manual and online help just don't make things clear enough. I'm sure I will have more questions as I work through this solution, but, so far, so good. Thanks so much for your help!
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now