我正在尝试通过查询填充网格区域。但我希望此查询根据下拉列表的选择进行更改。我有三个不同的查询,我希望它们根据下拉菜单进行交换。
我正在尝试使用IFS在以下查询之间切换:
=iferror(
IFS(B9="Value",
query(LOG!A4:U,"SELECT A, B, C, D, E, F, G, H, I, J, K WHERE A Is Not Null "
& IF(ISBLANK(B4),"", " AND K='"& LEFT(B4,7) &"'") & " "
& IF(D6<>"ALL", " AND N ='"& D6 &"'", "") & " "
& IF(E6<>"ALL", " AND Q ='"& E6 &"'", "") & " "
& IF(F6<>"ALL", " AND P ='"& F6 &"'", "") & " "
& IF(G6<>"ALL", " AND O ='"& G6 &"'", "") & " "
& IF(H6<>"ALL", " AND R ='"& H6 &"'", "") & " "
& IF(I6<>"ALL", " AND S ="& I6, "") & " "
& IF(ISBLANK(J6), "", " AND T ='"& LEFT(J6,7) &"'") & " "
& IF(ISBLANK(H9), "", " AND C >= date '" & text(H9,"yyyy-MM-dd") & "'" ) & " "
& IF(ISBLANK(I9), "", " AND D <= date '" & text(I9,"yyyy-MM-dd") & "'" ) & " "
,-1),
B9 = "value 2",
"other query
,"NO RESULTS")
那么单元格的值不是查询的值,而是这个公式只返回B9的值。
有没有办法根据单元格的下拉选择执行不同的查询?
提前致谢
编辑1:
=IFS(B9="WITHOUT COURSE"
,FILTER(PERSONNEL!A6:J
,(ISERROR(Match(PERSONNEL!A6:A,UNIQUE(filter(LOG!K4:K, VALUE(LOG!J4:J) = VALUE(RIGHT(B6,12)))),0)))
, (PERSONNEL!F6:F = E6) + (E6 = "ALL")
, (D6 = "ALL") + (PERSONNEL!D6:D = D6)
, (F6 = "ALL") + (PERSONNEL!G6:G = F6)
, (G6 = "ALL") + (PERSONNEL!E6:E = G6)
, (H6 = "ALL") + (PERSONNEL!I6:I = H6)
, (I6 = "ALL") + (PERSONNEL!H6:H = I6)
)
,B9="WITH COURSE"
,query(LOG!A4:U,"SELECT A, B, C, D, E, F, G, H, I, J, K WHERE A Is Not Null "
& IF(ISBLANK(B4),"", " AND K='"& LEFT(B4,7) &"'") & " "
& IF(D6<>"ALL", " AND N ='"& D6 &"'", "") & " "
& IF(E6<>"ALL", " AND Q ='"& E6 &"'", "") & " "
& IF(F6<>"ALL", " AND P ='"& F6 &"'", "") & " "
& IF(G6<>"ALL", " AND O ='"& G6 &"'", "") & " "
& IF(H6<>"ALL", " AND R ='"& H6 &"'", "") & " "
& IF(I6<>"ALL", " AND S ="& I6, "") & " "
& IF(ISBLANK(J6), "", " AND T ='"& LEFT(J6,7) &"'") & " "
& IF(ISBLANK(H9), "", " AND C >= date '" & text(H9,"yyyy-MM-dd") & "'" ) & " "
& IF(ISBLANK(I9), "", " AND D <= date '" & text(I9,"yyyy-MM-dd") & "'" ) & " "
& IF(ISBLANK(B6), "", " AND J ='"& RIGHT(B6,12) &"'") & " "
& IF(ISBLANK(B7), "", " AND L ='"& RIGHT(B7,12) &"'") & " "
& IF(ISBLANK(B8), "", " AND M ='"& B8 &"'") & " "
& IF(B9 = "EXPIRES IN", " AND (DATEDIFF(now(), C) / 30) >= U AND U > 0 AND (DATEDIFF(now(), C) / 30) <= " &E9 & " " ,"")
,-1)
)
答案 0 :(得分:0)
如果您删除iferror
,则会看到错误消息:
错误
IFS期望位置0之后的所有参数成对出现。
我猜你想设置默认值,如果公式给出错误值“NO RESULTS”。如果没有正确的括号,该公式将起作用:
=iferror(
IFS(B9="Value",
"some value",
B9 = "value 2",
"other query")
,"NO RESULTS")