cancel
Showing results for 
Search instead for 
Did you mean: 

Case and IF statement Interchangeably in SPS 10 onwords?

chandan_praharaj
Contributor
0 Kudos

Hi Experts,

Can you please tell me , which one to use, either case statement or IF statement, in calculated column in calc view.

I can be able to achieve my requirement, with both . So need to know which one is best? and any scenario where to use which statement.

Thanks !

Chandan

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member212236
Active Participant
0 Kudos

Hello Chandan,

Usage of CASE /  IF statement is purely based on the requirement.

A CASE will not help while handling complex logic especially in scenarios where we need to utilize relational operators like < or > and also in scenarios where we need to use "ranges" in the logic.

For example:

CASE with relational operators

CASE ("AGE">=10 AND <=20,'10-20',>=20 AND <=30,'20-30')

The above logic can be handled using IF as shown below:

IF ("AGE">=10 AND "AGE"<=20,'10-20',IF("AGE">=20 AND "AGE" <=30,'20-30'))

CASE with ranges


CASE ("EMPID",290-390,'XXXX',1-289,'YYYY','NONE')

In the above logic, there is a possibility where the range (1-289) can be considered as a Minus. But this can be handled very well using IF as shown below.

IF("EMPID">=290 AND "EMPID"<=390,'XXXX',IF("EMPID">=1 AND "EMPID"<=289,'YYYY','NONE'))

Kindly note that we have got a lot threads in SCN where similar questions have been discussed.

Regards,

Vinoth V