sorting - 我想在 Google 表格中识别重复项并保留最新的并删除另一个
问题描述
我想要识别我的数据中的重复项。一旦我有了这些数据,我想按日期对重复项进行排序并保留最新的数据。
由于里面的敏感信息,我不能不提供我的工作表的副本。
解决方案
像这样做:
=ARRAYFORMULA(IFERROR(VLOOKUP(UNIQUE(B:B),
QUERY({A:B}, "select Col2,Col1
order by toDate(Col1) desc
format Col1 'dd/mm/yyyy' ", 0), {2, 1}, 0)))
=ARRAYFORMULA(QUERY(IFERROR(VLOOKUP(UNIQUE(QUERY({Data!A:H},
"select Col3
where toDate(Col5) >= date '"&TEXT(A1, "yyyy-mm-dd")&"'
and toDate(Col5) <= date '"&TEXT(B1, "yyyy-mm-dd")&"'
order by toDate(Col1) desc ", 0)),
QUERY({Data!A:H},
"select Col3,Col1,Col2,Col4,Col5,Col6,Col7
where toDate(Col5) >= date '"&TEXT(A1, "yyyy-mm-dd")&"'
and toDate(Col5) <= date '"&TEXT(B1, "yyyy-mm-dd")&"'
order by toDate(Col1) desc
format Col5 'mm/dd/yyyy' ", 0), {2,3,1,4,5,6,7}, 0)),
"format Col1 'yyyy-nn-dd hh:mm:ss', Col5 'mm/dd/yyyy'"))
=ARRAYFORMULA(QUERY(IFERROR(VLOOKUP(UNIQUE(QUERY({Data!A:H},
"select Col2
where toDate(Col5) >= date '"&TEXT(A1, "yyyy-mm-dd")&"'
and toDate(Col5) <= date '"&TEXT(B1, "yyyy-mm-dd")&"'
order by toDate(Col1) desc ", 0)),
QUERY({Data!A:H},
"select Col2,Col1,Col3,Col4,Col5,Col6,Col7
where toDate(Col5) >= date '"&TEXT(A1, "yyyy-mm-dd")&"'
and toDate(Col5) <= date '"&TEXT(B1, "yyyy-mm-dd")&"'
order by toDate(Col1) desc
format Col5 'mm/dd/yyyy' ", 0), {2,1,3,4,5,6,7}, 0)),
"format Col1 'yyyy-mm-dd hh:mm:ss', Col5 'mm/dd/yyyy'"))
推荐阅读
- r - 部署应用程序时添加文件夹以在 RStudio Connect 中发布文件
- sql-server - 如何比较来自同一列和不同行但同一表的值?
- java - Spring Boot 执行器 + Kubernetes + 身份验证
- django - 如何将 Wagtail 表单用于无头 CMS?(没有模板)
- tcl - 如何循环直到我没有得到任何列出的选项作为提示
- javascript - 无法返回递归函数的最后结果
- python - 为什么我的代码没有退出无限循环?(Python)
- r - 计算时间序列中多年平均年增长率的函数
- flutter - 使用 Flutter 在 Android Studio Emulator 中将图像保存到图库时出现 FileSystemException
- python - 有没有办法阻止python文件关闭?