Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/google-sheets/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google sheets 谷歌表单中的异常查询_Google Sheets_Google Sheets Formula_Array Formulas_Google Sheets Query_Gs Vlookup - Fatal编程技术网

Google sheets 谷歌表单中的异常查询

Google sheets 谷歌表单中的异常查询,google-sheets,google-sheets-formula,array-formulas,google-sheets-query,gs-vlookup,Google Sheets,Google Sheets Formula,Array Formulas,Google Sheets Query,Gs Vlookup,我有这张桌子: A B 1 Company Code Year 2 61.490.561/0001-00 2018 3 61.490.561/0001-00 2017 4 61.490.561/0001-00 2016 5 84.586.205/0001-90 2018 6 84.586.205/0001-90 2017 7 84.586.2

我有这张桌子:

      A                     B
1     Company Code          Year
2     61.490.561/0001-00    2018
3     61.490.561/0001-00    2017
4     61.490.561/0001-00    2016
5     84.586.205/0001-90    2018
6     84.586.205/0001-90    2017
7     84.586.205/0001-90    2016
8     01.009.357/0001-01    2017
9     01.009.357/0001-01    2015
10    01.009.354/0001-60    2017
11    01.009.354/0001-60    2016
12    01.009.355/0001-04    2016
13    01.009.355/0001-04    2015
14    04.185.877/0001-55    2018
15    04.185.877/0001-55    2017
16    04.185.877/0001-55    2016
    ...
我需要:

  • 检查上一年的每个公司代码
  • 创建一个新表,每个公司代码有五行,年份值将遵循以下基本原理:去年+1、去年+2、去年+3、去年+4、去年+5
  • 在上面的示例中,它将如下所示:

          A                     B
    1     Company Code          Year
    2     61.490.561/0001-00    2023
    3     61.490.561/0001-00    2022
    4     61.490.561/0001-00    2021
    5     61.490.561/0001-00    2020
    6     61.490.561/0001-00    2019
    7     84.586.205/0001-90    2023
    8     84.586.205/0001-90    2022
    9     84.586.205/0001-90    2021
    10    84.586.205/0001-90    2020
    11    84.586.205/0001-90    2019
    12    01.009.357/0001-01    2022
    13    01.009.357/0001-01    2021
    14    01.009.357/0001-01    2020
    15    01.009.357/0001-01    2019
    16    01.009.357/0001-01    2018
    17    01.009.354/0001-60    2022
    18    01.009.354/0001-60    2021
    19    01.009.354/0001-60    2020
    20    01.009.354/0001-60    2019
    21    01.009.354/0001-60    2018
    22    01.009.355/0001-04    2021
    23    01.009.355/0001-04    2020
    24    01.009.355/0001-04    2019
    25    01.009.355/0001-04    2018
    26    01.009.355/0001-04    2017
    27    04.185.877/0001-55    2023
    28    04.185.877/0001-55    2022
    29    04.185.877/0001-55    2021
    30    04.185.877/0001-55    2020
    31    04.185.877/0001-55    2019
    
    我尝试过使用query,但就我的技能而言,这个似乎相当先进。我怎样才能开始呢

    =ARRAYFORMULA({A1:B1; SORT({
     QUERY(UNIQUE(IFERROR(VLOOKUP(INDEX(SORT(A2:B, 1, 1, 2, 0), , 1), 
     SORT(A2:B, 1, 1, 2, 0), {1, 2}, 0))), "select Col1,Col2+1 label Col2+1''", 0);
     QUERY(UNIQUE(IFERROR(VLOOKUP(INDEX(SORT(A2:B, 1, 1, 2, 0), , 1), 
     SORT(A2:B, 1, 1, 2, 0), {1, 2}, 0))), "select Col1,Col2+2 label Col2+2''", 0);
     QUERY(UNIQUE(IFERROR(VLOOKUP(INDEX(SORT(A2:B, 1, 1, 2, 0), , 1), 
     SORT(A2:B, 1, 1, 2, 0), {1, 2}, 0))), "select Col1,Col2+3 label Col2+3''", 0);
     QUERY(UNIQUE(IFERROR(VLOOKUP(INDEX(SORT(A2:B, 1, 1, 2, 0), , 1), 
     SORT(A2:B, 1, 1, 2, 0), {1, 2} ,0))) ,"select Col1,Col2+4 label Col2+4''", 0);
     QUERY(UNIQUE(IFERROR(VLOOKUP(INDEX(SORT(A2:B, 1, 1, 2, 0), , 1), 
     SORT(A2:B, 1, 1, 2, 0), {1, 2}, 0))), "select Col1,Col2+5 label Col2+5''", 0)}, 
     1, 1, 2, 0)})
    


    所以基本上是我第一次尝试谷歌电子表格

    如果在
    A2
    中的第二个选项卡(表2)中有:

    =INDEX(UNIQUE(Sheet1!$A$2:$A$16),ROUNDUP((ROW()-1)/5))
    
    在cel
    B2
    中:

    =MAXIFS(Sheet1!$B$2:$B$16,Sheet1!$A$2:$A$16,A2)+COUNTIF(A2:INDEX($A:$A,COUNTA(A:A)-1),A2)
    
    把它们都拖下来


    所以基本上是我第一次尝试谷歌电子表格

    如果在
    A2
    中的第二个选项卡(表2)中有:

    =INDEX(UNIQUE(Sheet1!$A$2:$A$16),ROUNDUP((ROW()-1)/5))
    
    在cel
    B2
    中:

    =MAXIFS(Sheet1!$B$2:$B$16,Sheet1!$A$2:$A$16,A2)+COUNTIF(A2:INDEX($A:$A,COUNTA(A:A)-1),A2)
    
    把它们都拖下来