Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/google-sheets/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
If statement 谷歌表单中的IFS公式_If Statement_Google Sheets_Google Sheets Formula - Fatal编程技术网

If statement 谷歌表单中的IFS公式

If statement 谷歌表单中的IFS公式,if-statement,google-sheets,google-sheets-formula,If Statement,Google Sheets,Google Sheets Formula,我正在谷歌搜索一个公式表 该公式基于“输入”表和“输出”表。“输入”表中有以下列: current_position, company_name, current_position_2, current_company_2 “输出”表中有“标题”和“账户名称”+ 公式应在“输出”的“标题”中,并注明: (一) 如果“当前职位”包含“首席运营官”、“首席执行官”、“首席运营官”(以及更多头衔),则取“公司名称”,并在“输出”下输入“账户名称” (二) 如果“当前职位”不包含“首席运营官”、“首席

我正在谷歌搜索一个公式表

该公式基于“输入”表和“输出”表。“输入”表中有以下列:

current_position, company_name, current_position_2, current_company_2
“输出”表中有“标题”和“账户名称”+

公式应在“输出”的“标题”中,并注明:

(一)

如果“当前职位”包含“首席运营官”、“首席执行官”、“首席运营官”(以及更多头衔),则取“公司名称”,并在“输出”下输入“账户名称”

(二)

如果“当前职位”不包含“首席运营官”、“首席执行官”、“首席运营官”(以及更多的头衔),“当前职位”包含“首席运营官”、“首席运营官”、“首席运营官”(以及更多的头衔),“输出”中的“标题”中的“当前职位”和“输出”中的“账户名称”中的“当前公司2”

(三)

如果“当前职位”或“当前职位”2均不包含“COO”、“CEO”、“CSO”(以及更多标题),则取“当前职位”并将“标题”放在“输出”和“当前职位”下,并将“账户名称”放在“输出”中。

注意:

function onOpen() { // to refresh 
SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Output').getRange('C2').setValue("=checkImput()");
}

function checkImput(){
  var imput = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Imput');
  var row = imput.getDataRange().getNumRows();
  var res = [];

  for(var x=2; x<=row; x++){
    var current_position = imput.getRange(x,7).getValue();
    var current_position2 = imput.getRange(x,43).getValue();
    var positions = "COO,CEO,CSO"; //Add new postion separated by comma

    if(positions.includes(current_position)){ // If "courrent_position" contains "COO", "CEO", "CSO" 
      res.push([current_position,imput.getRange(x,8).getValue()]); //Then put "current_position" in "Title" and "current_company" in Account Name
    }else{
      if(positions.includes(current_position2)){ //If "current_position" does not contain "COO", "CEO", "CSO" (and a lot more titles) AND "current_position_2" contain "COO", "CEO", "CSO" 
        res.push([current_position2,imput.getRange(x,44).getValue()]); //Then put "current_position_2" in "Title" in "Output" and "current_company_2" in "Account Name" in "Output"
      }else{ //If neither of "current_position" or "current_position_2 contains "COO", "CEO", "CSO" (and a lot more titles) 
        res.push([current_position2,imput.getRange(x,44).getValue()]); //Then take "current_position" and put in "Title" under "Output" and "Current_position_2" and put in "Account Name" in "Output"
      }
    }
  }
 return res;
}
尽可能多地,确保包括你到目前为止所做的工作,或者分享你所做的任何研究,以确保你是成功的

推荐:

function onOpen() { // to refresh 
SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Output').getRange('C2').setValue("=checkImput()");
}

function checkImput(){
  var imput = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Imput');
  var row = imput.getDataRange().getNumRows();
  var res = [];

  for(var x=2; x<=row; x++){
    var current_position = imput.getRange(x,7).getValue();
    var current_position2 = imput.getRange(x,43).getValue();
    var positions = "COO,CEO,CSO"; //Add new postion separated by comma

    if(positions.includes(current_position)){ // If "courrent_position" contains "COO", "CEO", "CSO" 
      res.push([current_position,imput.getRange(x,8).getValue()]); //Then put "current_position" in "Title" and "current_company" in Account Name
    }else{
      if(positions.includes(current_position2)){ //If "current_position" does not contain "COO", "CEO", "CSO" (and a lot more titles) AND "current_position_2" contain "COO", "CEO", "CSO" 
        res.push([current_position2,imput.getRange(x,44).getValue()]); //Then put "current_position_2" in "Title" in "Output" and "current_company_2" in "Account Name" in "Output"
      }else{ //If neither of "current_position" or "current_position_2 contains "COO", "CEO", "CSO" (and a lot more titles) 
        res.push([current_position2,imput.getRange(x,44).getValue()]); //Then take "current_position" and put in "Title" under "Output" and "Current_position_2" and put in "Account Name" in "Output"
      }
    }
  }
 return res;
}
在我的测试中,IFS函数非常有限,无法实现基于多个条件为不同列设置值的目标

我提出了一个替代解决方案,它检查“输入”表上的所有值,并根据上述3个条件返回“输出”表上的值:

已更新脚本:

function onOpen() { // to refresh 
SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Output').getRange('C2').setValue("=checkImput()");
}

function checkImput(){
  var imput = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Imput');
  var row = imput.getDataRange().getNumRows();
  var res = [];

  for(var x=2; x<=row; x++){
    var current_position = imput.getRange(x,7).getValue();
    var current_position2 = imput.getRange(x,43).getValue();
    var positions = "COO,CEO,CSO"; //Add new postion separated by comma

    if(positions.includes(current_position)){ // If "courrent_position" contains "COO", "CEO", "CSO" 
      res.push([current_position,imput.getRange(x,8).getValue()]); //Then put "current_position" in "Title" and "current_company" in Account Name
    }else{
      if(positions.includes(current_position2)){ //If "current_position" does not contain "COO", "CEO", "CSO" (and a lot more titles) AND "current_position_2" contain "COO", "CEO", "CSO" 
        res.push([current_position2,imput.getRange(x,44).getValue()]); //Then put "current_position_2" in "Title" in "Output" and "current_company_2" in "Account Name" in "Output"
      }else{ //If neither of "current_position" or "current_position_2 contains "COO", "CEO", "CSO" (and a lot more titles) 
        res.push([current_position2,imput.getRange(x,44).getValue()]); //Then take "current_position" and put in "Title" under "Output" and "Current_position_2" and put in "Account Name" in "Output"
      }
    }
  }
 return res;
}
函数onOpen(){//刷新
SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Output').getRange('C2').setValue(“=CheckInput()”);
}
函数checkImput(){
var imput=SpreadsheetApp.getActiveSpreadsheet().getSheetByName('imput');
var row=input.getDataRange().getNumRows();
var-res=[];

对于(var x=2;x1)*如果“当前位置”包含…则如果您共享到工作表的链接,则将“当前位置”放在“标题”中,并将“当前位置”放在帐户名中(创建链接时确保将链接的共享权限设置为“具有链接的任何人…”和“编辑器”),这将是获得帮助的最有效的方法。在我看来,这将需要一个额外的工作表/列表(包含所有您喜欢的标题)和一个公式,然后可以生成“输出”工作表的所有结果。我建议您手动输入“输出”请从您的帖子中列出至少一个案例。顺便说一句,正确的单词是“输入”,而不是“输入”我似乎不明白为什么它在第一行的标题和账户名中都写着CEO。它应该写:第二行:CEO |苹果第三行:CSO |亚马逊第四行:VP | Facebook,我应该把脚本复制到脚本编辑器中吗?更新脚本。只需复制并粘贴它。只要确保你的工作表的名称在电子表格上是“输入”和“输出”。我有添加了新脚本,但“输出表”上的“标题”和“帐户名”仍然为空。我尝试创建新的电子表格并刷新网站,但仍然无效。我尝试更改脚本,使其显示“当前位置2”的地方显示“当前位置2”因此,它对应于collum标题。我做错了什么吗?这里是电子表格的链接:我根据每个数据的列更改了脚本上的列号(例如,当前位置在您共享的工作表的第7列)它将起作用。那么我如何更改为科勒姆编号。输入:当前职位-科勒姆7公司名称-科勒姆8当前职位-科勒姆43当前公司-科勒姆44输出:标题-科勒姆3账户名称-科勒姆4