Hello @yourlaks
The separator between the operands in the operations is the comma symbol and not the semicolon. Furthermore, there are other issues:
The “IF” operation requires three parameters and not two. Your use of the parenthesis is incorrect, and other minor errors.
Please, remember you can nest multiple “IF” operations.
Your equation can be implemented as follows:
(function(){
var result = PREC(fieldname14*IF(fieldname7 == 'Sedentary', 1.2, IF(fieldname7 == 'Light', 1.4, IF(fieldname7 == 'Moderate', 1.6, IF(fieldname7 == 'Very', 1.75, IF(fieldname7 == 'Extra', 2, 2.3))))), 1);
jQuery('.tci-result-here').html(CONCATENATE('activity levels : ', result));
return result;
})()
However, there are other more preferred implementations because they are more readable, using the “if” conditional statement (do not confuse it with the “IF” operation), or with the “switch” conditional statement.
Using “if” conditional statement:
(function(){
var result = fieldname14, factor = 1;
if(fieldname7 == 'Sedentary') factor = 1.2;
if(fieldname7 == 'Light') factor =1.4;
if(fieldname7 == 'Moderate') factor = 1.6;
if(fieldname7 == 'Very') factor = 1.75;
if(fieldname7 == 'Extra') factor = 2;
if(fieldname7 == 'Active') factor = 2.3;
result = PREC(result*factor, 1);
jQuery('.tci-result-here').html(CONCATENATE('activity levels : ', result));
return result;
})()
Using “switch” conditional statement:
(function(){
var result = fieldname14, factor = 1;
switch(fieldname7)
{
case 'Sedentary': factor = 1.2; break;
case 'Light': factor =1.4; break;
case 'Moderate': factor = 1.6; break;
case 'Very': factor = 1.75; break;
case 'Extra': factor = 2; break;
case 'Active': factor = 2.3; break;
}
result = PREC(result*factor, 1);
jQuery('.tci-result-here').html(CONCATENATE('activity levels : ', result));
return result;
})()
Best regards.