连接行块

Concat blocks of rows

如何使用 arrayformula 连接出现在行块中的字符串?

Example spreadsheet here.

字符串数据在 A 列中。每个 5 行的块需要连接成一个单元格字符串,结果列在 B 列中。

    | Row | Column A   |
    |1 Hd |  -Header-  |
    |2    |1 This is   |
    |3    |the         |
    |4    |            |
    |5    |first row   |
    |6    |            |
    |7    |2 This is   |
    |8    |the         |
    |9    |            |
    |10   |second row  |
    |11   |            |
    |12   |3 This is   |
    |13   |the         |
    ...

B列我想看:

    1 This is the first row
    2 This is the second row
    3 This is the third row
    4 This is the fourth row

我得到的是:

    1 This is the first row
    1 This is the first row
    1 This is the first row
    1 This is the first row

我下面的公式(在单元格 B1 中)几乎有效:

=query({ArrayFormula(if(mod(row(A:A)+2,5)=1,if(A2:A<>"",trim(join(" ",indirect("A"&row()&":A"&row()+4))),),))},"select * where Col1 is not null",0)

(+2 和 A2 引用刚刚越过 header 行)

我期望的是 arrayformula 将单步执行行并将当前迭代行号传递给公式。显然不是。我的公式可以修复还是我需要以完全不同的方式解决问题?我很乐意听取所有意见。

尝试:

=INDEX(TRIM(
 FILTER(A2:A, MOD(ROW(A2:A)-2, 5)=0)&" "&
 FILTER(A2:A, MOD(ROW(A2:A)-3, 5)=0)&" "&
 FILTER(A2:A, MOD(ROW(A2:A)-4, 5)=0)&" "&
 FILTER(A2:A, MOD(ROW(A2:A)-5, 5)=0)&" "&
 FILTER(A2:A, MOD(ROW(A2:A)-6, 5)=0)))

Here is a copy 您的 sheet。在其中你会发现这个应该有效的公式:

=ARRAYFORMULA(TRANSPOSE(TRIM(QUERY(MID(QUERY({TEXT(ROW(A2:A21),"000")&A2:A21,INT((ROW(A2:A21)-2)/5)},"select MAX(Col1) group by Col1 pivot Col2"),4,100),,9^9))))