on 03-20-2016 11:33 PM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
95 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.