Google表格过滤功能,如果没有多列值

时间:2017-11-15 08:21:56

标签: filter google-sheets

我想从此表单上的Data!F:G中提取所有相关数据: https://docs.google.com/spreadsheets/d/18hJW4ojAbe1dUF1lDdSOI11cTEaMeJ6N-VZ6BB7LrAY/edit#gid=1162973857

我假设它是一个过滤功能,但是如果Dashboard!C1:C5中的字段为空,则要确保拉出所有数据。

=filter(Data!F:G, Data!A:A = C1, Data!B:B = C2, Data!C:C = C3, Data!D:D = C4, Data!E:E = C5)

在所有字段完成时起作用,但如果其中一个字段为空则不起作用。

谢谢!

2 个答案:

答案 0 :(得分:0)

看看是否有效

=iferror(query(Data!A:G, "select F, G where F is not null" &IF(len(C1), " and A = '"&C1&"'",)&IF(len(C2), " and B = '"&C2&"'",)&IF(len(C3), " and C = '"&C3&"'",)&IF(len(C4), " and D = '"&C4&"'",)&IF(len(C5), " and E = '"&C5&"'",),0), "no matches found")

答案 1 :(得分:0)

遗憾的是,Google表格过滤器中没有外卡,但您可以测试一列是否与此相同

=filter(Data!F:G,Data!A:A = if(C1="",Data!A:A,C1), Data!B:B = if(C2="",Data!B:B,C2), Data!C:C = if(C3="",Data!C:C,C3), Data!D:D = if(C4="",Data!D:D,C4), Data!E:E = if(C5="",Data!E:E,C5))

enter image description here

这可能有点整洁(相当于过滤器中的OR表达式)

=filter(Data!F:G,(C1="")+(Data!A:A=C1), (C2="")+(Data!B:B=C2), (C3="")+(Data!C:C=C3), (C4="")+(Data!D:D = C4), (C5="")+(Data!E:E=C5))