首页 > 解决方案 > 如果在某个日期之前,将返回查询中的日期替换为文本

问题描述

我有一份报告,其格式必须更改,删除几列,按类别过滤等。

G 列是日期“YYYY-MM-DD”列,出于我的目的,如果日期在今天之前,我需要将日期单元格更改为字符串“OOD”但是我似乎无法弄清楚我应该如何尝试这个.

我尝试了数组公式和替换等的各种组合,但似乎都破坏了查询。

=QUERY('test data'!1:994,"select C,G,J,K,O where F='FOOD' and C is not null order by K asc",0)

标签: google-sheetsgoogle-sheets-formulaarray-formulasgoogle-sheets-query

解决方案


试试这样:

=ARRAYFORMULA(QUERY({'test data'!A1:F994, 
 IF('test data'!G1:G994<TODAY(), "OOD", 'test data'!G1:G994), 'test data'!H1:994}, 
 "select Col3,Col7,Col10,Col11,Col15 
  where Col6='FOOD' 
    and Col3 is not null 
  order by Col11", 0))

推荐阅读