【发布时间】:2021-10-16 03:14:15
【问题描述】:
【问题讨论】:
标签: google-sheets google-sheets-formula
【问题讨论】:
标签: google-sheets google-sheets-formula
源自 MattKing 的回答,我添加了 transpose 以及串联部分的一些操作,以遵循您的 所需数据格式 的排序类型。这应该会为您提供与上面提供的相同的输出。
=arrayformula(split(flatten(transpose(A2:A6&" "&B1:D1)&"|"&transpose(B2:D6)),"|"))
地点:
A2:A6 是您的项目名称的范围B1:D1 是标题的范围B2:D6 是您的日期范围如果您希望日期中有空白单元格,例如下面的示例(如 cmets 部分中提到的 pgSystemTester):
您需要添加query 并排除那些没有日期的行。
=arrayformula(query({split(flatten(transpose(A2:A6&" "&B1:D1)&"|"&transpose(B2:D6)),"|")}, "where Col2 is not null"))
【讨论】:
只是为了提供另一种选择,并以此为动力(可能重复)question
=LET(x, $I$2:$L$4,
myrows, ROWS(x),
mycols, COLUMNS(x),
mycount, SEQUENCE(myrows*mycols),
car, $H$2:$H$4, color, $I$1:$L$1,
mylist, car&" "&color,
mycolumn, INDEX(mylist, CEILING(mycount/mycols,1), IF(MOD(mycount,mycols)=0, mycols,MOD(mycount,mycols))),
mydata, INDEX(x, CEILING(mycount/mycols,1), IF(MOD(mycount,mycols)=0, mycols,MOD(mycount,mycols))),
IF(SEQUENCE(1,2)=1, mycolumn, mydata))
【讨论】:
假设您的数据从单元格 Sheet1!A2 开始并无限向下延伸并无限延伸,试试这个:
=ARRAYFORMULA(QUERY(SPLIT(FLATTEN(Sheet1!A3:A&" "&Sheet1!B2:2&"|"&OFFSET(Sheet1!B3,,,9^9,9^9)),"|",0,0),"where Col2 is not null",0))
【讨论】:
A2 与A1 正确对齐(根据原始图形,您的假设是有道理的 - - 我的错)。然而,这产生了三列。我无法让您修改后的解决方案起作用。签出我发布的共享文件,并随时编辑或添加选项卡。我很好奇你的抵消方法。 docs.google.com/spreadsheets/d/…
您可以see a sample sheet here,每个选项卡上都有几个答案。
这是一个更新,其中包含一个从a different answer 窃取的公式,似乎可以解决这个问题。 (Player() 正式成为电子表格的 Jack Bauer...不要问他是如何完成工作的!)。
=INDEX(QUERY(SPLIT(FLATTEN(IF(B2:E="",,A2:A&" "&B1:E1&"×"&B2:E)), "×"),
"where Col2 is not null"))
确保将其放在右侧,以免其溢出。
老实说,这已经不再需要了,但我花了半个小时研究了它,如果有人睡不着觉,也许会有帮助。
/**
* Creates 2 Columns of Data
*
* @param {range} theRangeValues The Table Range.
* @return The two columns of data with all combinations based on rows and columns
* @customfunction
*/
function buildTwoColumnsData(theRangeValues) {
var allValues = [];
var i = 1;
var cCell = theRangeValues[0][i];
while (cCell != '' && i < theRangeValues[0].length) {
var theEnd = cCell;
var g = 1;
var rCell = theRangeValues[g][0];
while (rCell != '' && g < theRangeValues.length) {
allValues.push([rCell + " " + theEnd, theRangeValues[g][i]])
g++;
if (g < theRangeValues.length) {
rCell = theRangeValues[g][0];
}
}
i++;
if (i < theRangeValues[0].length) {
cCell = theRangeValues[0][i];
}
}
return allValues;
}
【讨论】: