我目前有一个具有以下列/行布局的 Google 表格:
firstname1, address1, orderdate1, item1, orderdate2, item2, orderdate3, item3
firstname2, address2, orderdate1, item1, orderdate2, item2
firstname3, address3, orderdate1, item1
我想要实现的期望输出如下所示:
firstname1, address1, orderdate1, item1
firstname1, address1, orderdate2, item2
firstname1, address1, orderdate3, item3
firstname2, address2, orderdate1, item1
firstname2, address2, orderdate2, item2
firstname3, address3, orderdate1, item1
这是我正在使用的公式:
=let(Σ,tocol(,1), reduce(Σ,indirect("Sheet1!C2:"&index(match(,0/(Sheet1!A:A<>"")))),lambda(a,c,vstack(if(iserror(a&""),Σ,a),if(len(c),hstack(index(Sheet1!A:B,row(c)),c),Σ)))))
但是输出是:
firstname1, address1, orderdate1
firstname1, address1, item1
firstname1, address1, orderdate2
firstname1, address1, item2
firstname1, address1, orderdate3
firstname1, address1, item2
firstname2, address2, orderdate1
firstname2, address2, item1
firstname2, address2, orderdate2
firstname2, address2, item2
firstname3, address3, orderdate1
firstname3, address3, item1
我不确定如何将订单日期和商品单元格分组在一起,以便它们保留在一行上
=query(
{A1:D;A1:B,E1:F;A1:B,G1:H},
"select * where Col1 is not null and Col3 is not null order by Col1"
)
在此公式中,三组列堆叠在一起:
{A1:D;A1:B,E1:F;A1:B,G1:H}
公式是动态的,它会自动响应额外的数据行。关键是:
where Col1 is not null
- 将忽略任何空白行and Col3 is not null
将忽略任何存在空白订单日期的行order by Col1
- 将按名字顺序排序。数据 - 之前
数据 - 之后