【问题标题】:Query to list data that's not listed in another column查询以列出未在另一列中列出的数据
【发布时间】:2020-04-01 03:36:33
【问题描述】:
=QUERY({startingdates!D2:D, Cancelledtours!D2:D},"Select Col1 where not(Col1) matches Col2")

这似乎适用于 A 列,但不适用于 D 列。我处于死胡同。有人可以帮忙吗?

表格-https://docs.google.com/spreadsheets/d/1zEQmNs48CsaaioQOcwuK97kcmnDLDfX-57nuXFaLujc/edit?usp=sharing

【问题讨论】:

  • D 列出现问题的原因是......它是唯一一个有任何取消日期的。
  • 你的公式是错误的,它适用于A列只是巧合
  • 我在 col A 中添加了第一个巡演日期,它起作用了,但也许我弄错了。现在不在电脑前。

标签: google-sheets filter google-sheets-formula array-formulas google-sheets-query


【解决方案1】:

您必须查找开始日期 - 查询目前只在同一行中查找是否有匹配项:

=ArrayFormula(QUERY({StartingDates!D2:D, isnumber(vlookup(StartingDates!D2:D,CancelledTours!D2:D,1,false))},"Select Col1 where Col2=false"))

或使用匹配略短:

=ArrayFormula(QUERY({StartingDates!D2:D, isnumber(match(StartingDates!D2:D,CancelledTours!D2:D,0))},"Select Col1 where Col2=false"))

颠倒逻辑,这也有效:

=ArrayFormula(QUERY({StartingDates!D2:D, isna(match(StartingDates!D2:D,CancelledTours!D2:D,0))},"Select Col1 where Col2=true"))

【讨论】:

  • 有趣但无关紧要,这绕过了 QUERY 中的 date literal“规则”
  • 好点,我并没有真正考虑过这一点,但直到我尝试(由您的参考确认)之前我不确定是否允许使用文字 true 和 false。我想知道你是否可以输入 'where not Col2' - 不,你不能,'not' 只适用于布尔表达式,所以你必须说 'where not Col2=true':-)
【解决方案2】:

尝试:

=FILTER(startingdates!D2:D, NOT(COUNTIF(Cancelledtours!D2:D, startingdates!D2:D)))

【讨论】:

    猜你喜欢
    • 2017-12-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-21
    • 1970-01-01
    相关资源
    最近更新 更多