Google 表查询如果为空

Google Sheets Query if blank

我有以下查询,它工作正常,除非 D 中没有匹配 F2 的值。我收到 #N/A 但不确定如何更正它以显示“0”。

=ABS(QUERY(Transactions,"SELECT SUM(E) WHERE D = '"&$F2&"' AND B > date '"&TEXT($C,"yyyy-mm-dd")&"' AND B <= date '"&TEXT($C,"yyyy-mm-dd")&"' GROUP BY D LABEL SUM(E) '' ",0))

你可以试试:

=IFERROR(ABS(QUERY(Transactions,
 "SELECT SUM(E) 
  WHERE D = '"&$F2&"' 
    AND B >  date '"&TEXT($C,"yyyy-mm-dd")&"' 
    AND B <= date '"&TEXT($C,"yyyy-mm-dd")&"' 
  GROUP BY D 
  LABEL SUM(E) '' ", 0)), 0)

使用的函数是IFERROR:

Returns the first argument if it is not an error value, otherwise returns the second argument if present, or a blank if the second argument is absent.

您可以在下面link:

查看它的使用和进一步解释