Hi (and sorry for ambiguous question Title, welcome to better ones)
I currently have a table of data looking like this:
CLASS Type A Type B Type C
A 1 3 7
B 2 4 8
C
D
Either through formulas (I don't see how) or a script, I am trying to get the combination of each 'Class' with each type, for example:
A1, A2, A3, A4, A7, A7 and A13 A14 A17 etc and A137 A138 etc (+ all other possibilities). So far I only managed to get the '2 digits' version.
Code so far below (in my data I have some extra columns which tell me what types I need for that specific class):
function expand(){
//create the sheet to use
var ss = SpreadsheetApp.getActive().getSheetByName('data');
//create blank array
var fin_resultAry = [];
//extract the range of data
var main_Range = ss.getRange('A2:D5').getValues();
//extract all the variations of data
var range1 = ss.getRange('E2:E3').getValues();
var range2 = ss.getRange('F2:F3').getValues();
var range3 = ss.getRange('G2:G3').getValues();
//create dictionary with variations
var var_dict = {1: range1, 2: range2, 3: range3}
//main for loop
for(var k = 0; k<main_Range.length;k++){
//push the initial no type variation
fin_resultAry.push(main_Range[k][0]);
//create the loop to check what class variations have the set value == true
for(var i = 1; i<=main_Range[k].length;i++){
if (main_Range[k][i] == true){
//for each of the variations add the var string to the initial class and push it
for(var j = 0; j<var_dict[i].length;j++){
fin_resultAry.push(main_Range[k][0] + " " + var_dict[i][j][0]);
}
}
}
}
return fin_resultAry;
}
Also note that my data has a lot of 'Classes' and more than 3 types which makes using formulas impossible as they are limited to X number of rows/characters/etc.