Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 2740

Re: Case and IF statement Interchangeably in SPS 10 onwords?

$
0
0

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


Viewing all articles
Browse latest Browse all 2740

Trending Articles