英文:
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)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论