Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 358967
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T12:20:58+00:00 2026-05-12T12:20:58+00:00

I was tasked with counting the number of distinct strings in a column in

  • 0

I was tasked with counting the number of distinct strings in a column in excel. A quick Google search later yielded the following formula found here:

=SUM(IF(FREQUENCY(MATCH(B2:B10,B2:B10,0),MATCH(B2:B10,B2:B10,0))>0,1))

Consider the data:

A
B
C
D
A
B
E
C

Now, the match function would return an array (as the first argument is an array):

1
2
3
4
1
2
7
3

So far so good. What I don’t understand is how the FREQUENCY function works here, in particular how it treats bins that are replicated (for example the bin 1 is replicated in the above data). The result of the frequency function is:

2
2
2
1
0
0
1
0
0

Thanks

Taras

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T12:20:58+00:00Added an answer on May 12, 2026 at 12:20 pm

    EDIT: I realised how your solution was working – amended to reflect this.

    FREQUENCY is searching for entries from your bins in the search array. Here’s how it’s working:

    Search array: 1 2 3 4 1 2 7 3

    Bins: 1 2 3 4 1 2 7 3

    Bin 1 => there are two 1’s => 2

    Bin 2 => there are two 2’s => 2

    Bin 3 => there are two 3’s => 2

    Bin 4 => there is one 4 => 1

    Bin 1 repeated => 1 already counted => 0

    Bin 2 repeated => 2 already counted => 0

    Bin 7 => there is one 7 => 1

    Bin 3 repeated => 3 already counted => 0

    It almost seems that the solution is exploiting a FREQUENCY quirk, that is, it won’t count the same bin twice, because you might expect the second bin with value 1 to be non-zero as well. But that’s how it works — as it will only count the number of occurrences for the first bin and not a duplicate bin, the number of rows with a value greater than zero will give you the number of distinct entries.

    Here’s an alternative approach which you might find useful. it can be used to calculate the number of distinct values:

    Suppose your string range is B2:B10. Fill down in another column

    =(MATCH(B2,B$2:B2,1)-(ROW(B2)-ROW(B$2)))>0
    

    The row should change as you copy down, so the second row should be, for example:

    =(MATCH(B3,B$2:B3,1)-(ROW(B3)-ROW(B$2)))>0
    

    This is signalling TRUE if the current row contains the first instance of a string (if you give it a couple of minutes you should be able to work out what it’s doing). Therefore, if you count the number of TRUEs with COUNTIF() then you should get the number of distinct strings.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been tasked with implementing Google Analytics inside our (ASP.NET) application. Here is the
I've been tasked to add some Doubleclick Spotlight tags to a number of pages
We are tasked with creating a reporting frameworks that does the following. Clients can
Alright, first you'll need to grab a barf bag. I've been tasked with optimizing
Im tasked to use OPEN XML SDK 2.0 and had encountered this problem. Is
I have been tasked to replace the hardware an existing Apache/Tomcat/MySQL application is running.
I've been tasked with writing a WCF service. (have not done this before.) I've
I've been tasked with creating an extremely heavy JavaScript site that of course must
I have been tasked with giving my company's website (~40 pages) a facelift. The
I'm tasked with getting a development environment set up for a new program at

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.