Thủ Thuật
  • TOP Thủ Thuật
    • Thủ Thuật Internet
    • Thủ Thuật Máy Tính
    • Thủ Thuật Tiện Ích
    • Thủ Thuật Phần Mềm
  • Chia Sẻ Kiến Thức
    • Học Excel
    • Học Word
    • Học Power Point
  • Games
  • Kênh Công Nghệ
  • Facebook
  • WordPress
  • SEO
No Result
View All Result
Thủ Thuật
  • TOP Thủ Thuật
    • Thủ Thuật Internet
    • Thủ Thuật Máy Tính
    • Thủ Thuật Tiện Ích
    • Thủ Thuật Phần Mềm
  • Chia Sẻ Kiến Thức
    • Học Excel
    • Học Word
    • Học Power Point
  • Games
  • Kênh Công Nghệ
  • Facebook
  • WordPress
  • SEO
No Result
View All Result
Thủ Thuật
No Result
View All Result
Home Chia Sẻ Kiến Thức Học Excel

How to Count Unique Values in Excel: A Comprehensive Guide to Formulas

How to Count Unique Values in Excel: A Comprehensive Guide to Formulas
6k
SHARES
19.5k
VIEWS
Share on Facebook

Nội Dung Bài Viết

Toggle
  • Understanding the Problem: Unique vs. Total Count
  • Method 1: The Helper Column Approach (Using COUNTIF)
    • The Concept
    • Implementation
    • Pros and Cons
  • Method 2: Advanced Array Formula (SUMPRODUCT + FREQUENCY)
    • Understanding the FREQUENCY Function
    • Step 1: Digitizing Data with MATCH
    • Step 2: Applying FREQUENCY
    • Step 3: Wrapping with SUMPRODUCT
    • Advantages of the Array Method
  • Comparison and Conclusion
    • Moving Forward
  • References

Data management in Excel is a vast field requiring various processing methods to handle different data types effectively. One of the most common yet challenging tasks for analysts and office workers is counting unique values within a list. While simple counting is easy, excluding duplicates requires a deeper understanding of Excel logic.

In this article, “Thủ Thuật” will guide you through the technical intricacies of counting unique items, exploring why this task can be tricky and how to solve it efficiently using both basic and advanced methods.

Understanding the Problem: Unique vs. Total Count

Before diving into the solutions, let’s look at a typical scenario. Imagine you manage a dataset containing sales records or employee attendance.

Initial Excel dataset showing columns for staff, date, and product namesInitial Excel dataset showing columns for staff, date, and product names

The requirement is straightforward: You need to determine how many distinct employees are in the “Staff” column, how many unique days are recorded in the “Date” column, or how many specific product types exist. The key constraint is that you must not count duplicate values.

If an employee’s name appears five times, it should only contribute “1” to the final count. Standard functions like COUNTA will give you the total number of rows, which is incorrect for this specific goal. We need more robust solutions.

Method 1: The Helper Column Approach (Using COUNTIF)

For users who prefer a step-by-step logical flow without complex array formulas, utilizing a helper column combined with the COUNTIF function is the most accessible method.

The Concept

The strategy here is to identify the first occurrence of a value. If a value appears for the first time, we mark it. If it appears again, we distinguish it so it can be excluded from the final sum.

Implementation

Let’s take the “Date” column (Column C) as an example. We will create a helper column (Column F) to calculate the occurrence index.

The formula used in cell F2 would be:
=COUNTIF($C$2:C2, C2)

Technical Breakdown:

  • Range ($C$2:C2): This is an expanding range. The first part $C$2 is an absolute reference, locking the starting point. The second part C2 is a relative reference. As you drag the formula down, the range grows (e.g., $C$2:C3, $C$2:C4).
  • Criteria (C2): This checks the value in the current row against the expanding range above it.
Xem thêm:  Tối Ưu Hóa Excel với Đối Tượng Application trong VBA

This logic results in a sequence of numbers. A result of “1” means the value is appearing for the first time. A result of “2” or higher indicates a duplicate.

Excel spreadsheet showing the result of the COUNTIF helper column methodExcel spreadsheet showing the result of the COUNTIF helper column method

To get the final count of unique values, you simply count how many cells in the helper column contain the value 1.

Result: In our example, the count is 9.

Pros and Cons

  • Pros: Easy to understand, debug, and audit. You can visually verify which rows are duplicates.
  • Cons: Manual and cumbersome. It requires modifying the dataset structure (adding columns). For datasets with thousands of rows, adding a calculation to every row can significantly increase file size and calculation time.

Method 2: Advanced Array Formula (SUMPRODUCT + FREQUENCY)

For advanced users or situations where you cannot alter the dataset structure, formulas involving SUMPRODUCT and FREQUENCY offer a powerful, professional solution. This method treats data as arrays, allowing for complex calculations within a single cell.

Understanding the FREQUENCY Function

The FREQUENCY function calculates how often values occur within a range of values, and then returns a vertical array of numbers. Its syntax is:
=FREQUENCY(data_array, bins_array)

The principle here is to count how many times values in the bins_array appear in the data_array. To adapt this for unique counting, we need to transform our text or date data into numerical positions that FREQUENCY can process.

Step 1: Digitizing Data with MATCH

Since FREQUENCY works with numbers, we first use the MATCH function to convert our dates or names into numerical indices.

The formula structure looks like this:
=MATCH(C2:C11, C2:C11, 0)

Using the MATCH function in Excel to find the position of itemsUsing the MATCH function in Excel to find the position of items

How it works:
The MATCH function looks at the array C2:C11 and returns the relative position of each item. If “27/06/2018” appears at position 7 and again at position 9, MATCH returns “7” for both instances because it always finds the first match.

If you inspect the formula result (using F9 in the formula bar), you obtain an array like {1, 2, 3, 4, 5, 6, 7, 7, 9...}. Note that duplicates result in repeated numbers.

Xem thêm:  Tạo Phím Tắt Ẩn và Xóa Sheet trong Excel

Result of combining FREQUENCY and MATCH functions in ExcelResult of combining FREQUENCY and MATCH functions in Excel

Step 2: Applying FREQUENCY

We now feed this array into the FREQUENCY function.

  • data_array: The result of the MATCH function (positions of our values).
  • bins_array: A sequential list of row numbers (1, 2, 3… corresponding to the rows of data).

When FREQUENCY processes this, it returns a count for each “bin”. Crucially, it returns the count only at the first occurrence of that number in the bin list and returns 0 for subsequent duplicates.

Result of combining FREQUENCY and MATCH functions in ExcelResult of combining FREQUENCY and MATCH functions in Excel

Step 3: Wrapping with SUMPRODUCT

The FREQUENCY function returns an array containing numbers greater than 0 (for unique items) and 0s (for duplicates/empty bins). To get the final count, we need to count how many values in this resulting array are greater than 0.

We use SUMPRODUCT to handle the array summation without requiring Ctrl+Shift+Enter (in most versions).

The logic involves:

  1. Checking if the Frequency result is >0. This returns TRUE or FALSE.
  2. Converting TRUE/FALSE into 1/0 using the double negative operator (--).
  3. Summing the result.

Final result using SUMPRODUCT to count unique valuesFinal result using SUMPRODUCT to count unique values

Final Formula:
=SUMPRODUCT(--(FREQUENCY(MATCH(Range, Range, 0), Row_Array)>0))

Result: The calculation returns 9, matching the result from Method 1.

Advantages of the Array Method

  • Efficiency: No helper columns are required.
  • Professionalism: Keeps the dataset clean and demonstrates a high level of Excel proficiency.
  • Scalability: Can be easily adapted for dynamic named ranges or Excel Tables.

Comparison and Conclusion

Both methods effectively solve the problem of counting unique values, but they serve different user needs.

The Helper Column (COUNTIF) method is ideal for ad-hoc analysis or for users who are comfortable with basic logic but intimidated by array formulas. It provides transparency, allowing you to filter and inspect duplicates manually.

The Array Formula (SUMPRODUCT + FREQUENCY) method represents a more advanced, “cleaner” approach. It is the preferred method for building dashboards or professional reports where adding extra columns is messy or prohibited. It requires a solid grasp of how Excel handles data arrays and Boolean logic.

Moving Forward

Mastering these techniques not only solves the immediate problem of counting unique entries but also sharpens your overall data processing mindset. Understanding how to manipulate arrays with FREQUENCY and MATCH opens the door to solving complex data extraction problems, such as creating dynamic lists of unique values.

For those dealing with varying dataset sizes where a fixed “Row_Array” (Bin) isn’t feasible, you can explore dynamic array functions like UNIQUE (available in Office 365) or use mathematical logic to generate the bin array automatically within the formula.

References

  • Microsoft Support: Count unique values among duplicates.
  • TechCrunch: Advanced Excel Data Analysis Techniques.
  • ExcelJet: usage of FREQUENCY and MATCH for unique counts.
Đánh Giá Bài Viết
Tuyết Nhi

Tuyết Nhi

Tôi là Tuyết Nhi - Nữ phóng viên trẻ đến từ Hà Nội. Với niềm đam mê công nghệ, khoa học kỹ thuật, tôi yêu thích và muốn chia sẻ đến mọi người những trải nghiệm, kinh nghiệm về các lĩnh vực công nghệ, kỹ thuật... Rất mong được quý độc giả đón nhận ❤️.

Related Posts

How to Generate Unique Random Numbers in Excel: A Comprehensive Guide
Học Excel

How to Generate Unique Random Numbers in Excel: A Comprehensive Guide

Master the Excel ERROR.TYPE Function to Categorize and Fix Formula Errors
Học Excel

Master the Excel ERROR.TYPE Function to Categorize and Fix Formula Errors

How to Print A5 Pages on A4 Paper: A Complete Guide
Học Excel

How to Print A5 Pages on A4 Paper: A Complete Guide

How to Create a Professional Plan vs. Actual Chart in Excel
Học Excel

How to Create a Professional Plan vs. Actual Chart in Excel

Discussion about this post

Trending.

Hướng Dẫn Tích Hợp Akismet Vào Contact Form 7: Giải Pháp Chống Spam “Tàng Hình” Hiệu Quả Nhất

Hướng Dẫn Tích Hợp Akismet Vào Contact Form 7: Giải Pháp Chống Spam “Tàng Hình” Hiệu Quả Nhất

Trích Xuất Dữ Liệu từ Báo Cáo Power BI Đã Xuất Bản Trên Web

Trích Xuất Dữ Liệu từ Báo Cáo Power BI Đã Xuất Bản Trên Web

Hướng Dẫn Cách Livestream Trên Facebook Bằng Điện Thoại Và Máy Tính Đơn Giản, Sắc Nét Từ A-Z

Hướng Dẫn Cách Livestream Trên Facebook Bằng Điện Thoại Và Máy Tính Đơn Giản, Sắc Nét Từ A-Z

World War 2: Strategy Games – Game Chiến Thuật Thế Chiến II Hấp Dẫn Trên Mobile

World War 2: Strategy Games – Game Chiến Thuật Thế Chiến II Hấp Dẫn Trên Mobile

Share Acc The Battle Cats Miễn Phí Mới Nhất 2025: Full Uber Rare & Cat Food

Share Acc The Battle Cats Miễn Phí Mới Nhất 2025: Full Uber Rare & Cat Food

Giới Thiệu

Thủ Thuật

➤ Website đang trong quá trình thử nghiệm AI biên tập, mọi nội dung trên website chúng tôi không chịu trách nhiệm. Bạn hãy cân nhắc thêm khi tham khảo bài viết, xin cảm ơn!

Chuyên Mục

➤ TOP Thủ Thuật

➤ Chia Sẻ Kiến Thức

➤ Kênh Công Nghệ

➤ SEO

➤ Games

Liên Kết

➤ Ketquaxskt.com

➤ TOP Restaurants

➤ Here Restaurant

➤

➤

Liên Hệ

➤ TP. Hải Phòng, Việt Nam

➤ 0931. 910. JQK

➤ Email: [email protected]

Website này cũng cần quảng cáo, không có tiền thì viết bài làm sao  ” Đen Vâu – MTP ”

DMCA.com Protection Status

© 2025 Thủ Thuật - Website chia sẻ kiến thức công nghệ hàng đầu Việt Nam

No Result
View All Result
  • TOP Thủ Thuật
    • Thủ Thuật Internet
    • Thủ Thuật Máy Tính
    • Thủ Thuật Tiện Ích
    • Thủ Thuật Phần Mềm
  • Chia Sẻ Kiến Thức
    • Học Excel
    • Học Word
    • Học Power Point
  • Games
  • Kênh Công Nghệ
  • Facebook
  • WordPress
  • SEO

© 2025 Thủ Thuật - Website chia sẻ kiến thức công nghệ hàng đầu Việt Nam