Jump to content

This topic is 7925 days old. Please don't post here. Open a new topic instead.

Recommended Posts

I've noticed that a lot of users in this forum make frequent use of the "Case" where I probably would have used "If"

Could someone exlain the difference, and why one might be prefered over the other?

Thanks!

--

Jason Wood

HeyWoody.com

Link to comment
Share on other sites

Hi:

It might help to think of If like a logic statement. "If [ this, then that. Else this]."

As you can see, If will only give you one of two results based on if the statement is true or not. Case, on the other hand, will evaluate the entire statement and will give results on the first value that is true, not just one result or the other.

I hope that makes sense.

Ken

Link to comment
Share on other sites

Ok, let me try this.

A typical case statement might look like this:

Case (test1, result1, test2, result2, test3, result3, default result)

If test1 qualifies, then you will get result1. If test2 qualifies, then you will get result2, and so on. If none qualify, you will get the default result. For example, suppose I have a field (we'll call it Num) that will be populated with numbers 1 through 4. I want a calc field (call it NumCalc) that will change the number to be spelled out ( "1" would be "one"). Sorry its a silly example, but bear with me. I would set up the NumCalc field like this:

Case (PatternCount(Num, "1"), "one" , PatternCount(Num, "2"), "two", PatternCount(Num, "3"), "three", PatternCount(Num, "4"), "four", "five").

Just think of it as an If statement with more than one test. Does that help??

Ken

Link to comment
Share on other sites

This topic is 7925 days old. Please don't post here. Open a new topic instead.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.