Google sheets 如果id重复,如何将行合并在一起(谷歌电子表格)

Google sheets 如果id重复,如何将行合并在一起(谷歌电子表格),google-sheets,google-sheets-formula,Google Sheets,Google Sheets Formula,我有这样的想法: id 3 200 31234 4 500 11111 3 google.com a-site-about-google 我想做的是,如果id相同,则将副本移动到另一列 id 3 200 31234 google.com a-site-about-google 4 500 11111 可以这样做吗?现在我建议使用自定义公式,但可以将其转换为通用脚本函数 代码如下: function CONCAT_BYID(arrSource) { var arrTar

我有这样的想法:

id  
3  200  31234
4  500  11111
3  google.com  a-site-about-google
我想做的是,如果id相同,则将副本移动到另一列

id
3 200 31234 google.com a-site-about-google
4 500 11111

可以这样做吗?

现在我建议使用自定义公式,但可以将其转换为通用脚本函数

代码如下:

function CONCAT_BYID(arrSource) { 
  var arrTarget = [],
      arrIndex = [],
      numColumns = arrSource[0].length;
  for (var i in arrSource) {
    var index = arrIndex.indexOf(arrSource[i][0]);
    var id = arrSource[i][0];
    if (index == -1) {
      arrIndex.push(id);
      arrTarget.push(arrSource[i]);
    } else {
      arrSource[i].shift();
      arrTarget[index] = arrTarget[index].concat(arrSource[i]);
      if (arrTarget[index].length > numColumns) numColumns = arrTarget[index].length;
    }
  }
  for (i in arrTarget) {
    while (arrTarget[i].length < numColumns) arrTarget[i].push('');
  }
  return arrTarget;
}
函数CONCAT_BYID(arrSource){
var arrTarget=[],
arrIndex=[],
numColumns=arrSource[0]。长度;
用于(arrSource中的var i){
var指数=arrIndex.indexOf(arrSource[i][0]);
var id=arrSource[i][0];
如果(索引==-1){
arrdex.push(id);
arrTarget.push(arrSource[i]);
}否则{
arrSource[i].shift();
arrTarget[index]=arrTarget[index].concat(arrSource[i]);
如果(arrTarget[index].length>numColumns)numColumns=arrTarget[index].length;
}
}
对于(目标中的i){
while(arrTarget[i]。长度
非常感谢您的帮助!