-1

I have something like this:

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

what I want to happen is if the id are the same move the duplicate to a different column.

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

Is it possible to do something like that?

PepperAddict
  • 888
  • 2
  • 10
  • 16

1 Answers1

1

Now I suggest a custom formula, but it can be converted into general script function.

enter image description here

The code is below:

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;
}