Google表格如何按日期对查询进行排序?

时间:2019-04-09 03:31:05

标签: google-sheets google-sheets-query

我有这个查询,它可以从某些选项卡中获取信息

=QUERY({
IFERROR(QUERY(General!A2:P,"select 'General',K,G,H,I,J where not G contains 'N/A' label 'General''' ",0),{"","","","","",""});
IFERROR(QUERY(Salud!A2:P,"select 'Salud',K,G,H,I,J where not G contains 'N/A' label 'Salud''' ",0),{"","","","","",""});
IFERROR(QUERY(Parejas!A2:P,"select 'Parejas',K,G,H,I,J where not G contains 'N/A' label 'Parejas''' ",0),{"","","","","",""});
IFERROR(QUERY('Paz Hogar'!A2:P,"select 'Paz Hogar',K,G,H,I,J where not G contains 'N/A' label 'Paz Hogar''' ",0),{"","","","","",""});
IFERROR(QUERY(Sustento!A2:P,"select 'Sustento',K,G,H,I,J where not G contains 'N/A' label 'Sustento''' ",0),{"","","","","",""});
IFERROR(QUERY(Hijos!A2:P,"select 'Hijos',K,G,H,I,J where not G contains 'N/A' label 'Hijos''' ",0),{"","","","","",""});
IFERROR(QUERY(Educacion!A2:P,"select 'Educacion',K,G,H,I,J where not G contains 'N/A' label 'Educacion''' ",0),{"","","","","",""});
IFERROR(QUERY(Otros!A2:P,"select 'Otros',K,G,H,I,J where not G contains 'N/A' label 'Otros''' ",0),{"","","","","",""});
IFERROR(QUERY(NA!A2:P,"select 'NA',K,G,H,I,J where not G contains 'N/A' label 'NA''' ",0),{"","","","","",""});
IFERROR(QUERY(a!A2:P,"select 'a',K,G,H,I,J where not G contains 'N/A' label 'a''' ",0),{"","","","","",""})},
"select * where Col1 is not null and not Col1 contains 'NA' order by Col3 ",0)

我的问题是不能按日期正确排序

enter image description here

我该怎么做?

Here is a demo sheet

编辑: 更新后的公式现在可以完美运行, 但是我正在尝试向查询中添加一列(E),当我添加它时,我收到了错误,没有Col7 如何在公式的第4个位置添加Col E? 我已经有几个小时了,没有运气;(

 =ARRAYFORMULA(SUBSTITUTE(QUERY(QUERY({QUERY({
 IFERROR(QUERY(General!A2:P,     "select 'General',K,G,H,I,J   where E <> '-'  label 'General'''",   0), {"","","","","",""});
 IFERROR(QUERY(Salud!A2:P,       "select 'Salud',K,G,H,I,J     where E <> '-'  label 'Salud'''",     0), {"","","","","",""});
 IFERROR(QUERY(Parejas!A2:P,     "select 'Parejas',K,G,H,I,J   where E <> '-'  label 'Parejas'''",   0), {"","","","","",""});
 IFERROR(QUERY('Paz Hogar'!A2:P, "select 'Paz Hogar',K,G,H,I,J where E <> '-'  label 'Paz Hogar'''", 0), {"","","","","",""});
 IFERROR(QUERY(Sustento!A2:P,    "select 'Sustento',K,G,H,I,J  where E <> '-'  label 'Sustento'''",  0), {"","","","","",""});
 IFERROR(QUERY(Hijos!A2:P,       "select 'Hijos',K,G,H,I,J     where E <> '-'  label 'Hijos'''",     0), {"","","","","",""});
 IFERROR(QUERY(Educacion!A2:P,   "select 'Educacion',K,G,H,I,J where E <> '-'  label 'Educacion'''", 0), {"","","","","",""});
 IFERROR(QUERY(Otros!A2:P,       "select 'Otros',K,G,H,I,J     where E <> '-'  label 'Otros'''",     0), {"","","","","",""});
 IFERROR(QUERY(NA!A2:P,          "select 'NA',K,G,H,I,J        where E <> '-'  label 'NA'''",        0), {"","","","","",""});
 IFERROR(QUERY(a!A2:P,           "select 'a',K,G,H,I,J         where E <> '-'  label 'a'''",         0), {"","","","","",""})},
 "where Col1 is not null and not Col1 contains 'NA'", 0),
 ARRAYFORMULA(DATE(20&RIGHT(QUERY({
 IFERROR(QUERY(General!A2:P,     "select 'General',K,G,H,I,J   where E <> '-'  label 'General'''",   0), {"","","","","",""});
 IFERROR(QUERY(Salud!A2:P,       "select 'Salud',K,G,H,I,J     where E <> '-'  label 'Salud'''",     0), {"","","","","",""});
 IFERROR(QUERY(Parejas!A2:P,     "select 'Parejas',K,G,H,I,J   where E <> '-'  label 'Parejas'''",   0), {"","","","","",""});
 IFERROR(QUERY('Paz Hogar'!A2:P, "select 'Paz Hogar',K,G,H,I,J where E <> '-'  label 'Paz Hogar'''", 0), {"","","","","",""});
 IFERROR(QUERY(Sustento!A2:P,    "select 'Sustento',K,G,H,I,J  where E <> '-'  label 'Sustento'''",  0), {"","","","","",""});
 IFERROR(QUERY(Hijos!A2:P,       "select 'Hijos',K,G,H,I,J     where E <> '-'  label 'Hijos'''",     0), {"","","","","",""});
 IFERROR(QUERY(Educacion!A2:P,   "select 'Educacion',K,G,H,I,J where E <> '-'  label 'Educacion'''", 0), {"","","","","",""});
 IFERROR(QUERY(Otros!A2:P,       "select 'Otros',K,G,H,I,J     where E <> '-'  label 'Otros'''",     0), {"","","","","",""});
 IFERROR(QUERY(NA!A2:P,          "select 'NA',K,G,H,I,J        where E <> '-'  label 'NA'''",        0), {"","","","","",""});
 IFERROR(QUERY(a!A2:P,           "select 'a',K,G,H,I,J         where E <> '-'  label 'a'''",         0), {"","","","","",""})},
 "select Col3 where Col1 is not null and not Col1 contains 'NA'", 0)
, 2), MONTH(MID(QUERY({
 IFERROR(QUERY(General!A2:P,     "select 'General',K,G,H,I,J   where E <> '-'  label 'General'''",   0), {"","","","","",""});
 IFERROR(QUERY(Salud!A2:P,       "select 'Salud',K,G,H,I,J     where E <> '-'  label 'Salud'''",     0), {"","","","","",""});
 IFERROR(QUERY(Parejas!A2:P,     "select 'Parejas',K,G,H,I,J   where E <> '-'  label 'Parejas'''",   0), {"","","","","",""});
 IFERROR(QUERY('Paz Hogar'!A2:P, "select 'Paz Hogar',K,G,H,I,J where E <> '-'  label 'Paz Hogar'''", 0), {"","","","","",""});
 IFERROR(QUERY(Sustento!A2:P,    "select 'Sustento',K,G,H,I,J  where E <> '-'  label 'Sustento'''",  0), {"","","","","",""});
 IFERROR(QUERY(Hijos!A2:P,       "select 'Hijos',K,G,H,I,J     where E <> '-'  label 'Hijos'''",     0), {"","","","","",""});
 IFERROR(QUERY(Educacion!A2:P,   "select 'Educacion',K,G,H,I,J where E <> '-'  label 'Educacion'''", 0), {"","","","","",""});
 IFERROR(QUERY(Otros!A2:P,       "select 'Otros',K,G,H,I,J     where E <> '-'  label 'Otros'''",     0), {"","","","","",""});
 IFERROR(QUERY(NA!A2:P,          "select 'NA',K,G,H,I,J        where E <> '-'  label 'NA'''",        0), {"","","","","",""});
 IFERROR(QUERY(a!A2:P,           "select 'a',K,G,H,I,J         where E <> '-'  label 'a'''",         0), {"","","","","",""})},
 "select Col3 where Col1 is not null and not Col1 contains 'NA'", 0), 4, 3)&1), LEFT(QUERY({
 IFERROR(QUERY(General!A2:P,     "select 'General',K,G,H,I,J   where E <> '-'  label 'General'''",   0), {"","","","","",""});
 IFERROR(QUERY(Salud!A2:P,       "select 'Salud',K,G,H,I,J     where E <> '-'  label 'Salud'''",     0), {"","","","","",""});
 IFERROR(QUERY(Parejas!A2:P,     "select 'Parejas',K,G,H,I,J   where E <> '-'  label 'Parejas'''",   0), {"","","","","",""});
 IFERROR(QUERY('Paz Hogar'!A2:P, "select 'Paz Hogar',K,G,H,I,J where E <> '-'  label 'Paz Hogar'''", 0), {"","","","","",""});
 IFERROR(QUERY(Sustento!A2:P,    "select 'Sustento',K,G,H,I,J  where E <> '-'  label 'Sustento'''",  0), {"","","","","",""});
 IFERROR(QUERY(Hijos!A2:P,       "select 'Hijos',K,G,H,I,J     where E <> '-'  label 'Hijos'''",     0), {"","","","","",""});
 IFERROR(QUERY(Educacion!A2:P,   "select 'Educacion',K,G,H,I,J where E <> '-'  label 'Educacion'''", 0), {"","","","","",""});
 IFERROR(QUERY(Otros!A2:P,       "select 'Otros',K,G,H,I,J     where E <> '-'  label 'Otros'''",     0), {"","","","","",""});
 IFERROR(QUERY(NA!A2:P,          "select 'NA',K,G,H,I,J        where E <> '-'  label 'NA'''",        0), {"","","","","",""});
 IFERROR(QUERY(a!A2:P,           "select 'a',K,G,H,I,J         where E <> '-'  label 'a'''",         0), {"","","","","",""})},
 "select Col3 where Col1 is not null and not Col1 contains 'NA'", 0),2)))}, 
 "select Col1,Col2,Col7,Col4,Col5,Col6 order by Col7", 0), 
 "format Col3 'dd-mmm-yy'", 0), "30-Nov-20", ""))

2 个答案:

答案 0 :(得分:0)

尝试这样:

=QUERY(QUERY({QUERY({
 IFERROR(QUERY(General!A2:P,     "select 'General',K,G,H,I,J   where not G contains 'N/A' label 'General'''",   0), {"","","","","",""});
 IFERROR(QUERY(Salud!A2:P,       "select 'Salud',K,G,H,I,J     where not G contains 'N/A' label 'Salud'''",     0), {"","","","","",""});
 IFERROR(QUERY(Parejas!A2:P,     "select 'Parejas',K,G,H,I,J   where not G contains 'N/A' label 'Parejas'''",   0), {"","","","","",""});
 IFERROR(QUERY('Paz Hogar'!A2:P, "select 'Paz Hogar',K,G,H,I,J where not G contains 'N/A' label 'Paz Hogar'''", 0), {"","","","","",""});
 IFERROR(QUERY(Sustento!A2:P,    "select 'Sustento',K,G,H,I,J  where not G contains 'N/A' label 'Sustento'''",  0), {"","","","","",""});
 IFERROR(QUERY(Hijos!A2:P,       "select 'Hijos',K,G,H,I,J     where not G contains 'N/A' label 'Hijos'''",     0), {"","","","","",""});
 IFERROR(QUERY(Educacion!A2:P,   "select 'Educacion',K,G,H,I,J where not G contains 'N/A' label 'Educacion'''", 0), {"","","","","",""});
 IFERROR(QUERY(Otros!A2:P,       "select 'Otros',K,G,H,I,J     where not G contains 'N/A' label 'Otros'''",     0), {"","","","","",""});
 IFERROR(QUERY(NA!A2:P,          "select 'NA',K,G,H,I,J        where not G contains 'N/A' label 'NA'''",        0), {"","","","","",""});
 IFERROR(QUERY(a!A2:P,           "select 'a',K,G,H,I,J         where not G contains 'N/A' label 'a'''",         0), {"","","","","",""})},
 "where Col1 is not null and not Col1 contains 'NA'", 0),
 ARRAYFORMULA(DATE(20&RIGHT(QUERY({
 IFERROR(QUERY(General!A2:P,     "select 'General',K,G,H,I,J   where not G contains 'N/A' label 'General'''",   0), {"","","","","",""});
 IFERROR(QUERY(Salud!A2:P,       "select 'Salud',K,G,H,I,J     where not G contains 'N/A' label 'Salud'''",     0), {"","","","","",""});
 IFERROR(QUERY(Parejas!A2:P,     "select 'Parejas',K,G,H,I,J   where not G contains 'N/A' label 'Parejas'''",   0), {"","","","","",""});
 IFERROR(QUERY('Paz Hogar'!A2:P, "select 'Paz Hogar',K,G,H,I,J where not G contains 'N/A' label 'Paz Hogar'''", 0), {"","","","","",""});
 IFERROR(QUERY(Sustento!A2:P,    "select 'Sustento',K,G,H,I,J  where not G contains 'N/A' label 'Sustento'''",  0), {"","","","","",""});
 IFERROR(QUERY(Hijos!A2:P,       "select 'Hijos',K,G,H,I,J     where not G contains 'N/A' label 'Hijos'''",     0), {"","","","","",""});
 IFERROR(QUERY(Educacion!A2:P,   "select 'Educacion',K,G,H,I,J where not G contains 'N/A' label 'Educacion'''", 0), {"","","","","",""});
 IFERROR(QUERY(Otros!A2:P,       "select 'Otros',K,G,H,I,J     where not G contains 'N/A' label 'Otros'''",     0), {"","","","","",""});
 IFERROR(QUERY(NA!A2:P,          "select 'NA',K,G,H,I,J        where not G contains 'N/A' label 'NA'''",        0), {"","","","","",""});
 IFERROR(QUERY(a!A2:P,           "select 'a',K,G,H,I,J         where not G contains 'N/A' label 'a'''",         0), {"","","","","",""})},
 "select Col3 where Col1 is not null and not Col1 contains 'NA'", 0)
, 2), MONTH(MID(QUERY({
 IFERROR(QUERY(General!A2:P,     "select 'General',K,G,H,I,J   where not G contains 'N/A' label 'General'''",   0), {"","","","","",""});
 IFERROR(QUERY(Salud!A2:P,       "select 'Salud',K,G,H,I,J     where not G contains 'N/A' label 'Salud'''",     0), {"","","","","",""});
 IFERROR(QUERY(Parejas!A2:P,     "select 'Parejas',K,G,H,I,J   where not G contains 'N/A' label 'Parejas'''",   0), {"","","","","",""});
 IFERROR(QUERY('Paz Hogar'!A2:P, "select 'Paz Hogar',K,G,H,I,J where not G contains 'N/A' label 'Paz Hogar'''", 0), {"","","","","",""});
 IFERROR(QUERY(Sustento!A2:P,    "select 'Sustento',K,G,H,I,J  where not G contains 'N/A' label 'Sustento'''",  0), {"","","","","",""});
 IFERROR(QUERY(Hijos!A2:P,       "select 'Hijos',K,G,H,I,J     where not G contains 'N/A' label 'Hijos'''",     0), {"","","","","",""});
 IFERROR(QUERY(Educacion!A2:P,   "select 'Educacion',K,G,H,I,J where not G contains 'N/A' label 'Educacion'''", 0), {"","","","","",""});
 IFERROR(QUERY(Otros!A2:P,       "select 'Otros',K,G,H,I,J     where not G contains 'N/A' label 'Otros'''",     0), {"","","","","",""});
 IFERROR(QUERY(NA!A2:P,          "select 'NA',K,G,H,I,J        where not G contains 'N/A' label 'NA'''",        0), {"","","","","",""});
 IFERROR(QUERY(a!A2:P,           "select 'a',K,G,H,I,J         where not G contains 'N/A' label 'a'''",         0), {"","","","","",""})},
 "select Col3 where Col1 is not null and not Col1 contains 'NA'", 0), 4, 3)&1), LEFT(QUERY({
 IFERROR(QUERY(General!A2:P,     "select 'General',K,G,H,I,J   where not G contains 'N/A' label 'General'''",   0), {"","","","","",""});
 IFERROR(QUERY(Salud!A2:P,       "select 'Salud',K,G,H,I,J     where not G contains 'N/A' label 'Salud'''",     0), {"","","","","",""});
 IFERROR(QUERY(Parejas!A2:P,     "select 'Parejas',K,G,H,I,J   where not G contains 'N/A' label 'Parejas'''",   0), {"","","","","",""});
 IFERROR(QUERY('Paz Hogar'!A2:P, "select 'Paz Hogar',K,G,H,I,J where not G contains 'N/A' label 'Paz Hogar'''", 0), {"","","","","",""});
 IFERROR(QUERY(Sustento!A2:P,    "select 'Sustento',K,G,H,I,J  where not G contains 'N/A' label 'Sustento'''",  0), {"","","","","",""});
 IFERROR(QUERY(Hijos!A2:P,       "select 'Hijos',K,G,H,I,J     where not G contains 'N/A' label 'Hijos'''",     0), {"","","","","",""});
 IFERROR(QUERY(Educacion!A2:P,   "select 'Educacion',K,G,H,I,J where not G contains 'N/A' label 'Educacion'''", 0), {"","","","","",""});
 IFERROR(QUERY(Otros!A2:P,       "select 'Otros',K,G,H,I,J     where not G contains 'N/A' label 'Otros'''",     0), {"","","","","",""});
 IFERROR(QUERY(NA!A2:P,          "select 'NA',K,G,H,I,J        where not G contains 'N/A' label 'NA'''",        0), {"","","","","",""});
 IFERROR(QUERY(a!A2:P,           "select 'a',K,G,H,I,J         where not G contains 'N/A' label 'a'''",         0), {"","","","","",""})},
 "select Col3 where Col1 is not null and not Col1 contains 'NA'", 0),2)))}, 
 "select Col1,Col2,Col7,Col4,Col5,Col6 order by Col7", 0), 
 "format Col3 'dd-mmm-yy'", 0)

空白日期修复:

=ARRAYFORMULA(SUBSTITUTE(QUERY(QUERY({QUERY({
 IFERROR(QUERY(General!A2:P,     "select 'General',K,G,H,I,J   where not G contains 'N/A' label 'General'''",   0), {"","","","","",""});
 IFERROR(QUERY(Salud!A2:P,       "select 'Salud',K,G,H,I,J     where not G contains 'N/A' label 'Salud'''",     0), {"","","","","",""});
 IFERROR(QUERY(Parejas!A2:P,     "select 'Parejas',K,G,H,I,J   where not G contains 'N/A' label 'Parejas'''",   0), {"","","","","",""});
 IFERROR(QUERY('Paz Hogar'!A2:P, "select 'Paz Hogar',K,G,H,I,J where not G contains 'N/A' label 'Paz Hogar'''", 0), {"","","","","",""});
 IFERROR(QUERY(Sustento!A2:P,    "select 'Sustento',K,G,H,I,J  where not G contains 'N/A' label 'Sustento'''",  0), {"","","","","",""});
 IFERROR(QUERY(Hijos!A2:P,       "select 'Hijos',K,G,H,I,J     where not G contains 'N/A' label 'Hijos'''",     0), {"","","","","",""});
 IFERROR(QUERY(Educacion!A2:P,   "select 'Educacion',K,G,H,I,J where not G contains 'N/A' label 'Educacion'''", 0), {"","","","","",""});
 IFERROR(QUERY(Otros!A2:P,       "select 'Otros',K,G,H,I,J     where not G contains 'N/A' label 'Otros'''",     0), {"","","","","",""});
 IFERROR(QUERY(NA!A2:P,          "select 'NA',K,G,H,I,J        where not G contains 'N/A' label 'NA'''",        0), {"","","","","",""});
 IFERROR(QUERY(a!A2:P,           "select 'a',K,G,H,I,J         where not G contains 'N/A' label 'a'''",         0), {"","","","","",""})},
 "where Col1 is not null and not Col1 contains 'NA'", 0),
 ARRAYFORMULA(DATE(20&RIGHT(QUERY({
 IFERROR(QUERY(General!A2:P,     "select 'General',K,G,H,I,J   where not G contains 'N/A' label 'General'''",   0), {"","","","","",""});
 IFERROR(QUERY(Salud!A2:P,       "select 'Salud',K,G,H,I,J     where not G contains 'N/A' label 'Salud'''",     0), {"","","","","",""});
 IFERROR(QUERY(Parejas!A2:P,     "select 'Parejas',K,G,H,I,J   where not G contains 'N/A' label 'Parejas'''",   0), {"","","","","",""});
 IFERROR(QUERY('Paz Hogar'!A2:P, "select 'Paz Hogar',K,G,H,I,J where not G contains 'N/A' label 'Paz Hogar'''", 0), {"","","","","",""});
 IFERROR(QUERY(Sustento!A2:P,    "select 'Sustento',K,G,H,I,J  where not G contains 'N/A' label 'Sustento'''",  0), {"","","","","",""});
 IFERROR(QUERY(Hijos!A2:P,       "select 'Hijos',K,G,H,I,J     where not G contains 'N/A' label 'Hijos'''",     0), {"","","","","",""});
 IFERROR(QUERY(Educacion!A2:P,   "select 'Educacion',K,G,H,I,J where not G contains 'N/A' label 'Educacion'''", 0), {"","","","","",""});
 IFERROR(QUERY(Otros!A2:P,       "select 'Otros',K,G,H,I,J     where not G contains 'N/A' label 'Otros'''",     0), {"","","","","",""});
 IFERROR(QUERY(NA!A2:P,          "select 'NA',K,G,H,I,J        where not G contains 'N/A' label 'NA'''",        0), {"","","","","",""});
 IFERROR(QUERY(a!A2:P,           "select 'a',K,G,H,I,J         where not G contains 'N/A' label 'a'''",         0), {"","","","","",""})},
 "select Col3 where Col1 is not null and not Col1 contains 'NA'", 0)
, 2), MONTH(MID(QUERY({
 IFERROR(QUERY(General!A2:P,     "select 'General',K,G,H,I,J   where not G contains 'N/A' label 'General'''",   0), {"","","","","",""});
 IFERROR(QUERY(Salud!A2:P,       "select 'Salud',K,G,H,I,J     where not G contains 'N/A' label 'Salud'''",     0), {"","","","","",""});
 IFERROR(QUERY(Parejas!A2:P,     "select 'Parejas',K,G,H,I,J   where not G contains 'N/A' label 'Parejas'''",   0), {"","","","","",""});
 IFERROR(QUERY('Paz Hogar'!A2:P, "select 'Paz Hogar',K,G,H,I,J where not G contains 'N/A' label 'Paz Hogar'''", 0), {"","","","","",""});
 IFERROR(QUERY(Sustento!A2:P,    "select 'Sustento',K,G,H,I,J  where not G contains 'N/A' label 'Sustento'''",  0), {"","","","","",""});
 IFERROR(QUERY(Hijos!A2:P,       "select 'Hijos',K,G,H,I,J     where not G contains 'N/A' label 'Hijos'''",     0), {"","","","","",""});
 IFERROR(QUERY(Educacion!A2:P,   "select 'Educacion',K,G,H,I,J where not G contains 'N/A' label 'Educacion'''", 0), {"","","","","",""});
 IFERROR(QUERY(Otros!A2:P,       "select 'Otros',K,G,H,I,J     where not G contains 'N/A' label 'Otros'''",     0), {"","","","","",""});
 IFERROR(QUERY(NA!A2:P,          "select 'NA',K,G,H,I,J        where not G contains 'N/A' label 'NA'''",        0), {"","","","","",""});
 IFERROR(QUERY(a!A2:P,           "select 'a',K,G,H,I,J         where not G contains 'N/A' label 'a'''",         0), {"","","","","",""})},
 "select Col3 where Col1 is not null and not Col1 contains 'NA'", 0), 4, 3)&1), LEFT(QUERY({
 IFERROR(QUERY(General!A2:P,     "select 'General',K,G,H,I,J   where not G contains 'N/A' label 'General'''",   0), {"","","","","",""});
 IFERROR(QUERY(Salud!A2:P,       "select 'Salud',K,G,H,I,J     where not G contains 'N/A' label 'Salud'''",     0), {"","","","","",""});
 IFERROR(QUERY(Parejas!A2:P,     "select 'Parejas',K,G,H,I,J   where not G contains 'N/A' label 'Parejas'''",   0), {"","","","","",""});
 IFERROR(QUERY('Paz Hogar'!A2:P, "select 'Paz Hogar',K,G,H,I,J where not G contains 'N/A' label 'Paz Hogar'''", 0), {"","","","","",""});
 IFERROR(QUERY(Sustento!A2:P,    "select 'Sustento',K,G,H,I,J  where not G contains 'N/A' label 'Sustento'''",  0), {"","","","","",""});
 IFERROR(QUERY(Hijos!A2:P,       "select 'Hijos',K,G,H,I,J     where not G contains 'N/A' label 'Hijos'''",     0), {"","","","","",""});
 IFERROR(QUERY(Educacion!A2:P,   "select 'Educacion',K,G,H,I,J where not G contains 'N/A' label 'Educacion'''", 0), {"","","","","",""});
 IFERROR(QUERY(Otros!A2:P,       "select 'Otros',K,G,H,I,J     where not G contains 'N/A' label 'Otros'''",     0), {"","","","","",""});
 IFERROR(QUERY(NA!A2:P,          "select 'NA',K,G,H,I,J        where not G contains 'N/A' label 'NA'''",        0), {"","","","","",""});
 IFERROR(QUERY(a!A2:P,           "select 'a',K,G,H,I,J         where not G contains 'N/A' label 'a'''",         0), {"","","","","",""})},
 "select Col3 where Col1 is not null and not Col1 contains 'NA'", 0),2)))}, 
 "select Col1,Col2,Col7,Col4,Col5,Col6 order by Col7", 0), 
 "format Col3 'dd-mmm-yy'", 0), "30-Nov-20", ""))

答案 1 :(得分:0)

这应该有效:

=ARRAYFORMULA(SUBSTITUTE(QUERY(QUERY({QUERY({
 IFERROR(QUERY(    General!A2:P, "select 'General',K,G,E,H,I,J   where not E contains '-'  label 'General'''",   0), {"","","","","","",""});
 IFERROR(QUERY(      Salud!A2:P, "select 'Salud',K,G,E,H,I,J     where not E contains '-'  label 'Salud'''",     0), {"","","","","","",""});
 IFERROR(QUERY(    Parejas!A2:P, "select 'Parejas',K,G,E,H,I,J   where not E contains '-'  label 'Parejas'''",   0), {"","","","","","",""});
 IFERROR(QUERY('Paz Hogar'!A2:P, "select 'Paz Hogar',K,G,E,H,I,J where not E contains '-'  label 'Paz Hogar'''", 0), {"","","","","","",""});
 IFERROR(QUERY(   Sustento!A2:P, "select 'Sustento',K,G,E,H,I,J  where not E contains '-'  label 'Sustento'''",  0), {"","","","","","",""});
 IFERROR(QUERY(      Hijos!A2:P, "select 'Hijos',K,G,E,H,I,J     where not E contains '-'  label 'Hijos'''",     0), {"","","","","","",""});
 IFERROR(QUERY(  Educacion!A2:P, "select 'Educacion',K,G,E,H,I,J where not E contains '-'  label 'Educacion'''", 0), {"","","","","","",""});
 IFERROR(QUERY(      Otros!A2:P, "select 'Otros',K,G,E,H,I,J     where not E contains '-'  label 'Otros'''",     0), {"","","","","","",""});
 IFERROR(QUERY(         NA!A2:P, "select 'NA',K,G,E,H,I,J        where not E contains '-'  label 'NA'''",        0), {"","","","","","",""});
 IFERROR(QUERY(          a!O2:P, "select 'a',K,G,E,H,I,J         where not E contains '-'  label 'a'''",         0), {"","","","","","",""})},
 "where Col1 is not null and not Col1 contains 'NA'", 0), DATE(20&RIGHT(QUERY({
 IFERROR(QUERY(    General!A2:P, "select 'General',K,G,E,H,I,J   where not E contains '-'  label 'General'''",   0), {"","","","","","",""});
 IFERROR(QUERY(      Salud!A2:P, "select 'Salud',K,G,E,H,I,J     where not E contains '-'  label 'Salud'''",     0), {"","","","","","",""});
 IFERROR(QUERY(    Parejas!A2:P, "select 'Parejas',K,G,E,H,I,J   where not E contains '-'  label 'Parejas'''",   0), {"","","","","","",""});
 IFERROR(QUERY('Paz Hogar'!A2:P, "select 'Paz Hogar',K,G,E,H,I,J where not E contains '-'  label 'Paz Hogar'''", 0), {"","","","","","",""});
 IFERROR(QUERY(   Sustento!A2:P, "select 'Sustento',K,G,E,H,I,J  where not E contains '-'  label 'Sustento'''",  0), {"","","","","","",""});
 IFERROR(QUERY(      Hijos!A2:P, "select 'Hijos',K,G,E,H,I,J     where not E contains '-'  label 'Hijos'''",     0), {"","","","","","",""});
 IFERROR(QUERY(  Educacion!A2:P, "select 'Educacion',K,G,E,H,I,J where not E contains '-'  label 'Educacion'''", 0), {"","","","","","",""});
 IFERROR(QUERY(      Otros!A2:P, "select 'Otros',K,G,E,H,I,J     where not E contains '-'  label 'Otros'''",     0), {"","","","","","",""});
 IFERROR(QUERY(         NA!A2:P, "select 'NA',K,G,E,H,I,J        where not E contains '-'  label 'NA'''",        0), {"","","","","","",""});
 IFERROR(QUERY(          a!O2:P, "select 'a',K,G,E,H,I,J         where not E contains '-'  label 'a'''",         0), {"","","","","","",""})},
 "select Col3 where Col1 is not null and not Col1 contains 'NA'", 0), 2), MONTH(MID(QUERY({
 IFERROR(QUERY(    General!A2:P, "select 'General',K,G,E,H,I,J   where not E contains '-'  label 'General'''",   0), {"","","","","","",""});
 IFERROR(QUERY(      Salud!A2:P, "select 'Salud',K,G,E,H,I,J     where not E contains '-'  label 'Salud'''",     0), {"","","","","","",""});
 IFERROR(QUERY(    Parejas!A2:P, "select 'Parejas',K,G,E,H,I,J   where not E contains '-'  label 'Parejas'''",   0), {"","","","","","",""});
 IFERROR(QUERY('Paz Hogar'!A2:P, "select 'Paz Hogar',K,G,E,H,I,J where not E contains '-'  label 'Paz Hogar'''", 0), {"","","","","","",""});
 IFERROR(QUERY(   Sustento!A2:P, "select 'Sustento',K,G,E,H,I,J  where not E contains '-'  label 'Sustento'''",  0), {"","","","","","",""});
 IFERROR(QUERY(      Hijos!A2:P, "select 'Hijos',K,G,E,H,I,J     where not E contains '-'  label 'Hijos'''",     0), {"","","","","","",""});
 IFERROR(QUERY(  Educacion!A2:P, "select 'Educacion',K,G,E,H,I,J where not E contains '-'  label 'Educacion'''", 0), {"","","","","","",""});
 IFERROR(QUERY(      Otros!A2:P, "select 'Otros',K,G,E,H,I,J     where not E contains '-'  label 'Otros'''",     0), {"","","","","","",""});
 IFERROR(QUERY(         NA!A2:P, "select 'NA',K,G,E,H,I,J        where not E contains '-'  label 'NA'''",        0), {"","","","","","",""});
 IFERROR(QUERY(          a!O2:P, "select 'a',K,G,E,H,I,J         where not E contains '-'  label 'a'''",         0), {"","","","","","",""})},
 "select Col3 where Col1 is not null and not Col1 contains 'NA'", 0), 4, 3)&1), LEFT(QUERY({
 IFERROR(QUERY(    General!A2:P, "select 'General',K,G,E,H,I,J   where not E contains '-'  label 'General'''",   0), {"","","","","","",""});
 IFERROR(QUERY(      Salud!A2:P, "select 'Salud',K,G,E,H,I,J     where not E contains '-'  label 'Salud'''",     0), {"","","","","","",""});
 IFERROR(QUERY(    Parejas!A2:P, "select 'Parejas',K,G,E,H,I,J   where not E contains '-'  label 'Parejas'''",   0), {"","","","","","",""});
 IFERROR(QUERY('Paz Hogar'!A2:P, "select 'Paz Hogar',K,G,E,H,I,J where not E contains '-'  label 'Paz Hogar'''", 0), {"","","","","","",""});
 IFERROR(QUERY(   Sustento!A2:P, "select 'Sustento',K,G,E,H,I,J  where not E contains '-'  label 'Sustento'''",  0), {"","","","","","",""});
 IFERROR(QUERY(      Hijos!A2:P, "select 'Hijos',K,G,E,H,I,J     where not E contains '-'  label 'Hijos'''",     0), {"","","","","","",""});
 IFERROR(QUERY(  Educacion!A2:P, "select 'Educacion',K,G,E,H,I,J where not E contains '-'  label 'Educacion'''", 0), {"","","","","","",""});
 IFERROR(QUERY(      Otros!A2:P, "select 'Otros',K,G,E,H,I,J     where not E contains '-'  label 'Otros'''",     0), {"","","","","","",""});
 IFERROR(QUERY(         NA!A2:P, "select 'NA',K,G,E,H,I,J        where not E contains '-'  label 'NA'''",        0), {"","","","","","",""});
 IFERROR(QUERY(          a!O2:P, "select 'a',K,G,E,H,I,J         where not E contains '-'  label 'a'''",         0), {"","","","","","",""})},
 "select Col3 where Col1 is not null and not Col1 contains 'NA'", 0), 2))}, 
 "select Col1,Col2,Col8,Col4,Col5,Col6 order by Col8", 0), 
 "format Col3 'dd-mmm-yy'", 0), "30-Nov-20", ""))