如何使用下拉菜单作为筛选器,包括一个“全部”选项?

huangapple go评论57阅读模式
英文:

How to use drop-down menus as filters including an "All" option?

问题

我有一个包含客户和订单数据的列表(日期、订购数量、价格等)。它的命名方式是[m]/[年],例如,1/23表示2023年1月。

我正在尝试创建一个单独的表格,其中包含能够更好地概览第一个表格中数据的统计信息。我想要按照选择的周期、类别和位置进行排序,这些选择可以从下拉菜单中进行。

我有一段代码,它从周期中获取表格名称,并使用类别和位置过滤关键词来汇总与所选过滤器相对应的所有订单的总额。

=SUMIFS(INDIRECT($A2&"!"&"F2:F");INDIRECT($A2&"!"&"C2:C");$B$2;INDIRECT($A2&"!"&"D2:D");$C$2)

这完全有效。然而,我想要为过滤器实现一个“全部”选项。

这不是问题,但同时汇总所有内容可能会带来些麻烦,因为过滤器可以选择任意组合的“全部”选项,这导致了三个过滤器之间的8种可能的组合。

我的思路是创建8个SUMIFS的不同分支,嵌套在一个IFS函数中。

是否有一种更简单、更优雅的在Google Sheets中进行过滤的方法?我不仅仅是在寻找解决方案,我需要一个指向正确方向的指针,以便我可以查阅学习。

英文:

I have a list with clients and data about their orders (date, amount ordered, price etc.)
It is named [m]/[year] e.g. 1/23 for January 2023.

I am trying to create a separate sheet with statistics that would give me a better overview of the data in the first sheet. I'd like to sort it by the period, category and location which you can select from a drop-down menu.

如何使用下拉菜单作为筛选器,包括一个“全部”选项?

I have this piece of code that takes the sheet name from Period and uses the Category and Location filter keywords to sum the totals from all orders corresponding with the selected filters.

=SUMIFS(INDIRECT($A2&"!"&"F2:F");INDIRECT($A2&"!"&"C2:C");$B$2;INDIRECT($A2&"!"&"D2:D");$C$2)

This works perfectly. However, I would like to implement an "All" option for the filters too.

如何使用下拉菜单作为筛选器,包括一个“全部”选项?

Summing up everything at the same time wouldn't be such a problem, but the filters can have any combination of "All" options selected which adds up to 8 possible combinations between the three filters.

如何使用下拉菜单作为筛选器,包括一个“全部”选项?

My thought process is to create 8 different branches of SUMIFS nested in an IFS function.

Is there a simpler, more elegant way of doing filters in Google Sheets? I am not just looking for t
he solution, I need a pointer in the right direction so that I can read up on it and learn it.

答案1

得分: 1

以下是要翻译的内容:

这里是一个通用示例,带有一些示例数据,以处理您的预期情况:

=sumif(A:A,if(D2="All","<>All",D2),B:B)

英文:

Here's a generalized example with some sample data to deal with your expected case scenario:

=sumif(A:A,if(D2=&quot;All&quot;,&quot;&lt;&gt;All&quot;,D2),B:B)

如何使用下拉菜单作为筛选器,包括一个“全部”选项?

huangapple
  • 本文由 发表于 2023年2月19日 18:19:52
  • 转载请务必保留本文链接:https://go.coder-hub.com/75499415.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定