Google sheets 请帮助我使用以下查询公式:

Google sheets 请帮助我使用以下查询公式:,google-sheets,google-sheets-formula,Google Sheets,Google Sheets Formula,这是我的数据: (批号和日期的组合总是唯一的) 所需结果: 我用了这个: =查询(生产!A:G,“选择A、B、C、D、G,其中A不是空标签C‘新批号’,“D‘新批号日期’”,1) 我不知道如何在我的查询公式中添加列旧分配的,请帮助 . 多谢各位 编辑: 有人能给我提供一个解决方案吗?它只使用查询(或嵌套查询),而不使用其他公式,如vlookup或filter或其他任何公式。试试这个: =arrayformula(查询({Production!A:G,iferror(vlookup(Produ

这是我的数据:
(批号和日期的组合总是唯一的)

所需结果:


我用了这个:
=查询(生产!A:G,“选择A、B、C、D、G,其中A不是空标签C‘新批号’,“D‘新批号日期’”,1)

我不知道如何在我的查询公式中添加列
旧分配的
,请帮助

.
多谢各位

编辑:
有人能给我提供一个解决方案吗?它只使用查询(或嵌套查询),而不使用其他公式,如vlookup或filter或其他任何公式。

试试这个:

=arrayformula(查询({Production!A:G,iferror(vlookup(Production!A1:A&“-”&Production!B1:B,{Production!C:C&“-”&Production!D:D,Production!G:G},2,false),),“选择Col1,Col2,Col8,Col3,Col4,Col7,其中Col1不是空标签Col3'新批号',Col4'新批号日期',Col8'旧分配',”

或仅用于
查询

=
query(
{
query({Production!A:G},"select Col7 where Col6 is not null order by Col4,Col3 label Col7 'OLD ASSIGNED'",1),
query({Production!A:G},"select Col1,Col2,Col3,Col4,Col7 where Col1 is not null order by Col2,Col1 label Col3 'NEW LOT NO.', Col4 'NEW LOT NO. DATE' ",1)
},
"select Col2,Col3,Col1,Col4,Col5,Col6 order by Col5,Col3",1)
这仅使用
查询
,因此您需要为结果选择排序顺序,因为批号277以不同的日期顺序出现在a列和C列中

如果您想要原始排序顺序,那么如果您准备使用
序列
,它可以像这样工作:

=
query(
{
query({Production!A:G},"select Col7 where Col6 is not null order by Col4,Col3 label Col7 'OLD ASSIGNED'",1),
query({Production!A:G,sequence(counta(Production!A:A)+countblank(Production!A:A),1)},"select Col1,Col2,Col3,Col4,Col7,Col8 where Col1 is not null order by Col2,Col1 label Col3 'NEW LOT NO.', Col4 'NEW LOT NO. DATE' ",1)
},
"select Col2,Col3,Col1,Col4,Col5,Col6 order by Col7",1)

sequence
用于生成行号序列(因为
row()
需要
arrayformula
——这是您不想要的)。序列中的数字范围是
counta(生产!A:A)+countblank(生产!A:A)
这是生产表中的行数。

非常感谢!我真的很好奇,你能不能给我一个只使用查询(或嵌套查询)的解决方案,而不使用其他公式,比如vlookup或filter之类的,可以吗?如果不可能,请告诉我?我已经添加了一个替代方案。谢谢!我有三个问题:(1)我用
“&textjoin(|)”,true,query({if(Production!A2:A”,Production!A2:A&“-”&Production!B2:B,)},“在Col1不为null的情况下选择Col1”,0)和“
”从公式中替换为
”&textjoin(|),true,if(Production!A2:A”,“Production!A2:A&-”&Production!B2:B),)&“
,它工作了,我只是想确认它是否正确?太好了。前两个查询的问题可能是如何在工作表中实现它。我的测试表还可以,但很高兴你得到了你想要的:-)。