Reputation: 1
I have a value in a google sheet which is "test2".
Using Google apps script I have created a custom formula TE using the formula below.
I input the formula in the adjacent cell =TE(test2), the value it outputs is incorrect. In the script below, it keeps picking up test 1 value always as -125 and the if statements are not working.
Please can anyone help?
function TE(AL) {
var RH = -110;
var HF = -30;
var AC = '';
if (AL = "test1") {
AC = -125;
} else if (AL = "test2") {
AC = -135;
} else {
AC = -100000;
}
var TC = RH + HF + AC;
Logger.log (TC);
return TC;
}
Upvotes: 0
Views: 53
Reputation: 64100
Try this:
function TE(AL) {
var RH=-110;
var HF=-30;
var AC='';
if(AL=="test1")
{
AC=-125;
}else if(AL=="test2")
{
AC=-135;
}else{
AC=-100000;
}
var TC=RH+HF+AC;
return TC;
}
Here's what it looks like on my spreadsheet:
Upvotes: 1