Jump to content
  • 0

CASE 'Else If' Logic


kpcollier
 Share

Question

I'm in need of some help with some CASE logic. 

First, let me lay down how this is suppose to go in my app. There are 4 fields in question: SQFT, PPSQFT, SQFT_Override, PPSQFT_Override. 

The most common case is going to be (SQFT * PPSQFT), which is a value for sqft * price per sqft. These values are automatically calculated from other fields. However, the user can 'Override' these values to output another number. So,

  • it would only be (SQFT * PPSQFT) if 'SQFT_Override' and 'PPSQFT_Override' both are blank, or null. 
  • If 'PPSQFT_Override' is not null, it would be (SQFT * PPSQFT_Override). 
  • If 'SQFT_Override' is not null, it would be (SQFT_Override * PPSQFT)
  • If 'SQFT_Override' and 'PPSQFT_Override' are both not null, it would be (SQFT_Override * PPSQFT_Override)

In formula terms, this is the closest I got:

CASE

WHEN [@field:PPSQFT_Override] is not null AND [@field:SQFT_Override] is not null

THEN [@field:SQFT_Override] * [@field:PPSQFT_Override]

ELSE WHEN [@field:PPSQFT_Override] is not null AND [@field:SQFT_Override] is null
  
THEN [@field:SQFT] * [@field:PPSQFT_Override]
  
ELSE [@field:SQFT] * [@field:PPSQFT]

END

Then I obviously found out that you cannot use 'Else When' or 'Else If' in CASE statements. 

What is the best way to rewrite a CASE statement to include a third condition?

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

I'm a rook. Figured it out. Just list the other conditions and it will sort through :rolleyes:

CASE

WHEN [@field:PPSQFT_Override] is not null AND [@field:SQFT_Override] is not null

THEN [@field:SQFT_Override] * [@field:PPSQFT_Override]

WHEN [@field:PPSQFT_Override] is not null AND [@field:SQFT_Override] is null
  
THEN [@field:SQFT] * [@field:PPSQFT_Override]
  
WHEN [@field:PPSQFT_Override] is null AND [@field:SQFT_Override] is not null
  
THEN [@field:SQFT_Override] * [@field:PPSQFT]
  
ELSE [@field:SQFT] * [@field:PPSQFT]

END

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...