Skip to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

If vs Case

Featured Replies

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

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

  • Author

I understand "If" fully from my QBasic days... maybe you could give me a syntax example for Case (I still don't quite get how it works).

--

Jason Wood

HeyWoody.com

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

  • Author

I had to lookup PatternCount() but now it all makes sense!

I had been using nested If statements to achieve these results, so I sure am glad I asked!

--

Jason Wood

HeyWoody.com

That is the main reason for using Case statements. Nested If's can be horrible to debug. Apparently Case statements execute faster too.

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.