本篇文章给大家带来了关于excel的相关知识,其中主要介绍了关于COUNTIF的两种用法,包括了提取不重复名单和计算不重复人数,下面一起来看一下,希望对大家有帮助。
相关学习推荐:excel教程
提取不重复名单
如下图所示,要提取C列不重复的名单。
曾经的高能公式为:
=INDEX(C:C,1+MATCH(,COUNTIF(E$1:E1,C$2:C$15),))&""
注意是数组公式,编辑完成后,要按Ctrl+Shift+回车。
首先利用COUNTIF函数,在公式所在位置上方的单元格区域中,分别查找C$2:C$15单元格区域每个数据的个数。返回一个由0和1构成的数组,如果C$2:C$15单元格区域的元素在公式上方出现过,结果就是1;如果没出现,结果就是0。
本例中,COUNTIF函数的第一参数是一个扩展的区域,前面公式提取的结果会被后面的公式重复利用进行判断。
再利用MATCH函数,在COUNTIF函数返回的数组中查找第一个0的位置,也就是查找首次出现的数据所在的位置。
由于数据表的标题行占了1行,将这个数字加1,就是需要提取的不重复数据在数据表中列的位置。
接下来利用INDEX函数,以MATCH函数的计算结果作为索引值,提取C列对应位置上的数据。
如果你使用的是Excel 2021,就可以一脚踢飞COUNTIF,下面这个公式更简单:
=UNIQUE(C2:C14)
计算不重复人数
如下图所示,要计算C列不重复的人数。
曾经的高能公式为:
=SUMPRODUCT(1/COUNTIF(A2:A14,A2:A14))
这个公式中包含了一个简单的数学逻辑:
任意一个数据重复出现N次,N个1/N的和值为1。
公式中“COUNTIF(A2:A14,A2:A14)”部分是数组计算,作用是分别统计A2:A14单元格区域中每个元素出现的次数。
运算过程相当于:
=COUNTIF(A2:A14,A2)
=COUNTIF(A2:A14,A3)
……
=COUNTIF(A2:A14,A14)
返回内存数组结果为:
{2;2;2;2;2;2;2;2;2;2;1;1;1}
再使用1除以返回的内存数组,得到以下结果:
{0.5;0.5;0.5……;1;1;1}
用1除,即相当于计算COUNTIF函数所返回内存数组的倒数。
为便于理解,把这一步的结果中的小数部分使用分数代替,结果为:
{1/2;1/2;1/2;1/2;……;1;1;1}
如果单元格的值在区域中是唯一值,这一步的结果是1。
如果重复出现两次,这一步的结果就有两个1/2。
如果单元格的值在区域中重复出现3次,结果就有3个1/3…
即每个元素对应的倒数合计起来结果仍是1。
最后用SUMPRODUCT函数求和,得出不重复的人员总数。
如果你使用的是Excel 2021,就可以一掌拍死COUNTIF,下面这个公式更简单:
=COUNTA(UNIQUE(A2:A12))
先使用UNIQUE提取出A列的不重复名单,然后用COUNTA计算个数。
相关学习推荐:excel教程
The above is the detailed content of Two high-power usage updates for COUNTIF in Excel. For more information, please follow other related articles on the PHP Chinese website!

This tutorial explains how to calculate the median of numerical data in Excel using the MEDIAN function. The median, a key measure of central tendency, identifies the middle value in a dataset, offering a more robust representation of central tenden

Master Google Sheets COUNTIF: A Comprehensive Guide This guide explores the versatile COUNTIF function in Google Sheets, demonstrating its applications beyond simple cell counting. We'll cover various scenarios, from exact and partial matches to han

This tutorial provides a comprehensive guide to sharing Excel workbooks, covering various methods, access control, and conflict resolution. Modern Excel versions (2010, 2013, 2016, and later) simplify collaborative editing, eliminating the need to m

This tutorial explores various methods for converting .xls files to .jpg images, encompassing both built-in Windows tools and free online converters. Need to create a presentation, share spreadsheet data securely, or design a document? Converting yo

This tutorial clarifies the function of Excel names and demonstrates how to define names for cells, ranges, constants, or formulas. It also covers editing, filtering, and deleting defined names. Excel names, while incredibly useful, are often overlo

This tutorial clarifies the distinction between standard deviation and standard error of the mean, guiding you on the optimal Excel functions for standard deviation calculations. In descriptive statistics, the mean and standard deviation are intrinsi

This Excel tutorial demonstrates how to calculate square roots and nth roots. Finding the square root is a common mathematical operation, and Excel offers several methods. Methods for Calculating Square Roots in Excel: Using the SQRT Function: The

Unlock the Power of Google Sheets: A Beginner's Guide This tutorial introduces the fundamentals of Google Sheets, a powerful and versatile alternative to MS Excel. Learn how to effortlessly manage spreadsheets, leverage key features, and collaborate


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

SublimeText3 Mac version
God-level code editing software (SublimeText3)

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

Dreamweaver Mac version
Visual web development tools