Hi,
I’ll try to explain the process with an example. I’ll assume that the value of choices in the DropDown are: A,B,C, and D, furthermore I will assume that the value of calculated field is:
1000, if the value of fieldname5 field is: A
500, if the value of fieldname5 field is: B
250, if the value of fieldname5 field is: C
125, if the value of fieldname5 field is: D
In the development process there are multiple solutions for a same problem, so you can use any of following equations in the calculated field.
An equation very easy to understand:
(function(){
var f = fieldname5;
if(f == 'A') return 1000;
if(f == 'B') return 500;
if(f == 'C') return 250;
if(f == 'D') return 125;
})()
Using the “switch” statement:
(function(){
var f = fieldname5;
switch(fieldname5){
case 'A': return 1000;
case 'B': return 500;
case 'C': return 250;
case 'D': return 125;
}
})()
Nesting the ternary operator, used in your original solution:
(fieldname5 == 'A')?1000:((fieldname5=='B')?500:((fieldname5=='C')?150:125))
Nesting the operation “IF”, included in the plugin:
IF(fieldname5=='A',1000,IF(fieldname5=='B',500,IF(fieldname5=='C',150,125)))
Note: I really prefer the two first equation, because they are easier to understand.
Best regards.