0

I have a spreadsheet A which is the source of data and spreadsheet B where this data should be put to. The data needs to be transposed, but there's also a number of conditions like Month, Name and Attribute. So there's 3 matching parameters to meet(Name, Month, Attribute). And this is what I can't get my head around.

This is the code I've come up with, but it's no good since the transpose function doesn't work at all. And how to apply matching to this code is hard for me.

function transpose() 

  var sourcess = SpreadsheetApp.openById();  
  var sourcesheet = sourcess.getSheetByName();
  var sourcerange = sourcesheet.getRange((row2col()));
  var sourcevalues = sourcerange.getValues();

  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var destsheet = ss.getSheetByName();
  var destrange = destsheet.getRange(); 

  destrange.setValues(sourcevalues);

function row2col(row) {
  return row[0].map(function(elem) {return [elem];});

Any help is very much appreciated. Here is a test file of what this should look like

Rubén
  • 34,714
  • 9
  • 70
  • 166
  • I've used [this transpose](https://stackoverflow.com/a/16705104/7215091). It's works great. There are other answers on that same page as well. – Cooper Dec 20 '17 at 01:40
  • You should not call this operation "transpose". There is a standard Google Spreadsheet function called =TRANSPOSE() which is doing what amounts to actual matrix transposition. What you need is more akin to denormalization or making of a pivot, so you should call your function "denormalize" or "pivot" (and ask for solutions to those). – ttarchala Dec 21 '17 at 13:41

0 Answers0