【问题标题】:Formula for Outputting New Row for Each Non-Empty Cell in Specific Range为特定范围内的每个非空单元格输出新行的公式
【发布时间】:2019-02-08 21:08:27
【问题描述】:

我有一个数据范围,需要按特定子范围内的非空单元格过滤,同时为该子范围内的每个非空单元格生成一个新行。

请注意以下示例表,其中包含输入数据和所需输出:

https://docs.google.com/spreadsheets/d/1c1lOtXpGbY9MwYHEoFIe1fxgW7TnygcgImCIIp2gzqM/edit?usp=sharing

对于每个非空白的“Type 1 - 4”单元格,应输出一个新行,其中包含来自输入行的日期、名称、类型和值.

为了完成这个需要什么公式或函数?

我对使用QUERY、VLOOKUP 和FILTER 并不陌生,但我无法通过公式获得所需的输出,甚至无法想出任何可以接近的方法。

【问题讨论】:

    标签: google-sheets


    【解决方案1】:
    =ARRAYFORMULA({"Date", "Name", "Type", "Value"; QUERY({
     QUERY({B3:I, IF(F3:F<>"", $F$2, )},
     "select Col1, Col2, Col9, Col5 where Col9 is not null", 0);
     QUERY({B3:I, IF(G3:G<>"", $G$2, )},
     "select Col1, Col2, Col9, Col6 where Col9 is not null", 0);
     QUERY({B3:I, IF(H3:H<>"", $H$2, )},
     "select Col1, Col2, Col9, Col7 where Col9 is not null", 0);
     QUERY({B3:I, IF(I3:I<>"", $I$2, )},
     "select Col1, Col2, Col9, Col8 where Col9 is not null", 0)},
     "select * order by Col1 asc", 0)})
    

    【讨论】:

      【解决方案2】:

      另一个答案,在概念上类似于 player0,但更简单一些。它在形成完整的范围数组后selects 列:

      =arrayformula( 
        query( 
          { 
            B2:B, C2:C, iferror(F2:F/0, F2), F2:F; 
            B2:B, C2:C, iferror(G2:G/0, G2), G2:G; 
            B2:B, C2:C, iferror(H2:H/0, H2), H2:H; 
            B2:B, C2:C, iferror(I2:I/0, I2), I2:I 
          }, 
          "where Col4 is not null 
           order by Col1", 
          0 
        ) 
      )
      

      通过Google Product Forum。

      【讨论】:

        猜你喜欢
        • 2018-07-09
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-11-05
        • 1970-01-01
        • 1970-01-01
        • 2020-03-09
        相关资源
        最近更新 更多