如何在Google表中过滤数据,以便只包含每个名称的最后20个项目?

发布于 2025-01-24 01:37:16 字数 314 浏览 5 评论 0原文

我有一个Google电子表格,其1000行还要多,并且每周更新,每行都包含名称,并做出了3个决定之一。我想自动化它,并在单独的表格中具有名称和数字决定的表格,每个名称的持续20个。

所需的结果看起来像 此屏幕截图

我是JavaScript的初学者,并且对我如何使用应用程序脚本进行此操作的任何想法或结构将非常欢迎。

I have a google spreadsheet that have more then 1000 rows and it gets updated weekly, each row contain name and one of 3 decisions was made. I want to automate it and have in a separate sheet a table with names and count decisions in numbers and just last 20 for each name.

The desired result would look like
this screenshot.

I'm a beginner in JavaScript and any idea or structure on how I can do this using App Script will be very welcome.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

探春 2025-01-31 01:37:16

您可以在Sheet1!af1中使用代理商通过代理创建降级序列:

=arrayformula( 
  { 
    "Descending ordinal by agent"; 
    iferror( 1 / 
      countifs( 
        E2:E, E2:E, 
        row(E2:E), ">=" & row(E2:E) 
      ) 
    ^ -1 ) 
  } 
)

然后 insert>表格并将此公式插入新表格的单元 a1 :

=query( 
  Sheet1!A1:AF, 
  "select E, count(E) 
   where AD is not null 
   and AF <= 20 
   group by E 
   pivot AD", 
  1 
)

该公式将按名称和决策给出计数,只查看序数为20或更少的行。请参阅新的

You can create descending ordinals by agent with this formula in cell Sheet1!AF1:

=arrayformula( 
  { 
    "Descending ordinal by agent"; 
    iferror( 1 / 
      countifs( 
        E2:E, E2:E, 
        row(E2:E), ">=" & row(E2:E) 
      ) 
    ^ -1 ) 
  } 
)

Then Insert > Sheet and insert this formula in cell A1 of the new sheet:

=query( 
  Sheet1!A1:AF, 
  "select E, count(E) 
   where AD is not null 
   and AF <= 20 
   group by E 
   pivot AD", 
  1 
)

The formula will give counts by name and decision, only looking at rows where the ordinal is 20 or less. See the new Solution sheet in your sample spreadsheet.

初见 2025-01-31 01:37:16

尝试:

=INDEX({QUERY({Sheet1!E2:E, Sheet1!AD2:AD, 
 COUNTIFS(Sheet1!E2:E, Sheet1!E2:E, ROW(Sheet1!E2:E), ">="&ROW(Sheet1!E2:E))}, 
 "select Col1,count(Col1) where Col1 is not null and Col3 <= 20 
  group by Col1 pivot Col2 label Col1'Name'"), 
 {"Total"; MMULT(QUERY(QUERY({Sheet1!E2:E, Sheet1!AD2:AD, 
 COUNTIFS(Sheet1!E2:E, Sheet1!E2:E, ROW(Sheet1!E2:E), ">="&ROW(Sheet1!E2:E))}, 
 "select count(Col1) where Col1 is not null and Col3 <= 20 group by Col1 
  pivot Col2"), "offset 1", 0)*1, {1;1;1})}})

try:

=INDEX({QUERY({Sheet1!E2:E, Sheet1!AD2:AD, 
 COUNTIFS(Sheet1!E2:E, Sheet1!E2:E, ROW(Sheet1!E2:E), ">="&ROW(Sheet1!E2:E))}, 
 "select Col1,count(Col1) where Col1 is not null and Col3 <= 20 
  group by Col1 pivot Col2 label Col1'Name'"), 
 {"Total"; MMULT(QUERY(QUERY({Sheet1!E2:E, Sheet1!AD2:AD, 
 COUNTIFS(Sheet1!E2:E, Sheet1!E2:E, ROW(Sheet1!E2:E), ">="&ROW(Sheet1!E2:E))}, 
 "select count(Col1) where Col1 is not null and Col3 <= 20 group by Col1 
  pivot Col2"), "offset 1", 0)*1, {1;1;1})}})

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文