跳到主要内容

如何使用Excel中的条件对过滤后的数据/列表进行计数?

您可能会注意到,无论您是否过滤了表格,COUNTIF函数都会忽略过滤并返回固定值。 在某些情况下,您需要根据特定条件对过滤的数据进行计数,那么如何完成呢? 在本文中,我将介绍几种在Excel中快速过滤Countif过滤数据/列表的方法。


Countif 通过在 Excel 中添加帮助列来使用条件筛选数据

在本文中,我将以下表为例。 在这里,我在 Salesman 列中过滤掉了 Julie 和 Nicole。

原始数据:

过滤数据:

此方法将引导您添加一个额外的帮助列,然后您可以应用 COUNTIFS 函数对 Excel 中的过滤数据进行计数。 (备注:此方法要求您在执行以下步骤之前过滤原始表。)

1. 在原始过滤表之外找到一个空白单元格,比如说单元格 G2,输入 = IF(B2 =“ Pear”,1,“”),然后将“填充手柄”拖动到所需的范围。 (请注意: 在公式 = IF(B2 =“ Pear”,1,“”),B2是您要计算的单元格,“ Pear”是您要计算的标准。)

现在除了原始过滤表之外,还添加了一个辅助列。 “1”表示它在 B 列中是梨,而空白表示它在 B 列中不是梨。

2。 找到一个空白单元格并输入公式 =COUNTIFS(B2:B18,"Pear",G2:G18,"1"),然后按 输入 键。 (请注意: 在公式 =COUNTIFS(B2:B18,"Pear",G2:G18,"1"),则B2:B18和G2:G18是您要计算的范围,“梨”和“ 1”是您要计算的条件。)

现在您将立即获得计数。 请注意计数 不会改变 如果您禁用过滤或更改过滤。

仅在指定范围内对可见单元格求和/计数/平均,而忽略隐藏或过滤的单元格/行/列

通常,SUM/Count/Average 函数将对指定范围内的所有单元格进行计数,该单元格是否隐藏/过滤。而小计函数只能求和/计数/平均,忽略隐藏行。然而,Kutools for Excel 可见的/清晰可见/平均可见度 函数将忽略任何隐藏的单元格,行或列,轻松地计算指定范围。


广告总数仅计算平均可见单元格

通过Excel函数使用条件对Countif过滤的数据

如果您希望计数随着过滤器的变化而变化,则可以在Excel中应用SUMPRODUCT函数,如下所示:
在空白单元格中输入公式 =SUMPRODUCT(SUBTOTAL(3,OFFSET(B2:B18,ROW(B2:B18)-MIN(ROW(B2:B18)),,1)),ISNUMBER(SEARCH("Pear",B2:B18))+0),然后按 输入 键。

注意丝带 公式太难记了吗? 将公式另存为自动文本条目,以供日后再次使用!
阅读全文...     免费试用

笔记:
(1)在上式中,B2:B18是您要计算的范围,“ Pear”是您要计算的标准。
(2) 返回值 会改变 当您禁用过滤或过滤更改时。

根据Excel列中的条件轻松将范围分为多个工作表

与复杂的数组公式相比,将所有过滤的记录保存到新的工作表中,然后应用Count函数对过滤的数据范围或列表进行计数可能要容易得多。

Kutools for Excel的 拆分数据 实用程序可以帮助Excel用户根据原始范围的一列中的条件轻松地将范围分为多个工作表。


广告分割数据0


相关文章

最佳办公生产力工具

🤖 Kutools 人工智能助手:基于以下内容彻底改变数据分析: 智能执行   |  生成代码  |  创建自定义公式  |  分析数据并生成图表  |  调用 Kutools 函数...
热门特色: 查找、突出显示或识别重复项   |  删除空白行   |  合并列或单元格而不丢失数据   |   不使用公式进行四舍五入 ...
超级查询: 多条件VLookup    多值VLookup  |   跨多个工作表的 VLookup   |   模糊查询 ....
高级下拉列表: 快速创建下拉列表   |  依赖下拉列表   |  多选下拉列表 ....
列管理器: 添加特定数量的列  |  移动列  |  切换隐藏列的可见性状态  |  比较范围和列 ...
特色功能: 网格焦点   |  设计图   |   大方程式酒吧    工作簿和工作表管理器   |  资源库 (自动文本)   |  日期选择器   |  合并工作表   |  加密/解密单元格    按列表发送电子邮件   |  超级筛选   |   特殊过滤器 (过滤粗体/斜体/删除线...)...
前 15 个工具集12 文本 工具 (添加文本, 删除字符,...)   |   50+ 图表 类型 (甘特图,...)   |   40+ 实用 公式 (根据生日计算年龄,...)   |   19 插入 工具 (插入二维码, 从路径插入图片,...)   |   12 转化 工具 (小写金额转大写, 货币兑换,...)   |   7 合并与拆分 工具 (高级组合行, 分裂细胞,...)   |   ... 和更多

使用 Kutools for Excel 增强您的 Excel 技能,体验前所未有的效率。 Kutools for Excel 提供了 300 多种高级功能来提高生产力并节省时间。  单击此处获取您最需要的功能...

产品描述


Office Tab 为 Office 带来选项卡式界面,让您的工作更加轻松

  • 在Word,Excel,PowerPoint中启用选项卡式编辑和阅读,发布者,Access,Visio和Project。
  • 在同一窗口的新选项卡中而不是在新窗口中打开并创建多个文档。
  • 每天将您的工作效率提高50%,并减少数百次鼠标单击!
Comments (17)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
When i change the filter, the count will change automatically ?
This comment was minimized by the moderator on the site
Is there a way to modify the formula for filtered data if I'm wanting to gather the information but for both pears and oranges?
This comment was minimized by the moderator on the site
Hi there,

With the first method, you can enter the following formula in the helper column: =IF(B2="Pear",1,IF(B2="Orange",1,"")
And then use the following formula to get the total count: =COUNTIFS(G2:G18,1)

Amanda
This comment was minimized by the moderator on the site
Sweet, this works!
This comment was minimized by the moderator on the site
hey i want to count value greater than 1 but with filtered visible data, can you help?
This comment was minimized by the moderator on the site
Hi,
I need help calculating the percentage of PP students (column F) with SEN (column E) who have s or b (column G)

Here's the formula I've been trying to use but it's not working.

Any help/advice appreciated.

=SUMPRODUCT(ISNUMBER(MATCH($E$2:$E$30,{"<>"},0))*ISNUMBER(MATCH($F$2:$F$30,{"<>"},0))*ISNUMBER(MATCH($T$2:$T$30,{"s","b"},0)))/SUMPRODUCT(ISNUMBER(MATCH($E$2:$E$30,{"<>"},0))*ISNUMBER(MATCH($F$2:$F$30,{"<>"},0)))

Claire
This comment was minimized by the moderator on the site
How about if “pear” needs to be a number value “<0” what do you use instead of (search?
This comment was minimized by the moderator on the site
Hi Sib,
You can apply the COUNTIFS functions to count items with two or more criteria. In the case of this webpage, you can use the formulas =COUNTIFS(B2:B21,"Pear",C2:C21,"<0") to count the pears whose amount is less than 0.
However, the count result is solid and won’t change when you change the filter.
This comment was minimized by the moderator on the site
Thanks a lot. It's really excellent! Thanks once a lot.
This comment was minimized by the moderator on the site
Excellent!!! Now able to filter and countif based on creiteria.
This comment was minimized by the moderator on the site
How would I add another criteria to the filtered data formula?
This comment was minimized by the moderator on the site
Hi Kane,
Which kind of filter criteria do you want to add? More detailed information can help we understand and solve your problem quicker.
This comment was minimized by the moderator on the site
Same with my question. How to count filtered if there are two criteria "Pear" for fruit and "Julie" for salesman?

Thanks.
This comment was minimized by the moderator on the site
Hi,
In this situation, I guess a helper column I introduced in the first method may be easier to count.
This comment was minimized by the moderator on the site
AWESOME, I used the formula, and it was exactly what I need. thanks!!
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations