+ Reply to Thread
Results 1 to 6 of 6

Counting appearence of number just once

  1. #1
    Registered User
    Join Date
    10-13-2010
    Location
    Somewhere, Somewhere
    MS-Off Ver
    Excel 2003
    Posts
    3

    Counting appearence of number just once

    Hello guys.

    I hope my question would be easy for ya :-). I have a column with numbers (approx 500 numbers), which may repeat (e.g. 1, 1, 2, 3, 4, 5, 6, 6). All the numbers in the column, BUT when it appears more than once, I need to count it just once (that means that result of the example would be 6). I guess there is some way throught COUNTIF but I have no idea how.

    could you help me?

    Thanks in advance
    Last edited by 5173; 10-13-2010 at 10:17 AM.

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Counting appearence of number just once

    Try:

    =SUMPRODUCT((A1:A100<>"")/COUNTIF(A1:A100,A1:A100&""))
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Registered User
    Join Date
    10-13-2010
    Location
    Somewhere, Somewhere
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Counting appearence of number just once

    Wow, it seems to be working. Excel just had a problem with comma in the second part of the formula. But it looks it is working with semi-colon.

    Could you please just briefly explain what I am doing with the formula??

    Thanks in advance.

  4. #4
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Counting appearence of number just once

    The Sumproduct() part checks for non blank entries in the range.. and assigns TRUE/FALSE based on if the cells have an entry or are blank.

    The COUNTIF part counts how many of each entry there are and produces an array of numbers.

    When you divide the SUMPRODUCT TRUE/FALSE array by the COUNTIF array, the TRUE/FALSEs are converted to 1/0, respectively..

    1 divided by each value in the COUNTIF range produces a decimal value equivalent to a fractional portion of the repeated value... eg, if you have three 2's in your range, then the COUNTIF produces, three 3's where the 2's are positioned in the range ... the Sumproduct will produce TRUEs at those same positions.. which convert to 1's... so then 1/3 would be .33333333 (this occurs 3 times adding up to 1). When all is said and done, you will be left with a SUMPRODUCT array of fractions.. and all the fractions for a repeated part add up to 1.. so you end up with the number of unique entries.

    If you use the formula Auditor with the formula on a small range (say A1:A10) then you will see the steps and it may make more sense.

  5. #5
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Counting appearence of number just once

    Quote Originally Posted by 5173
    Excel just had a problem with comma in the second part of the formula. But it looks it is working with semi-colon.
    If you post a sensible location in your profile you might find you get personalised solutions... the delimiters vary by locale ... specifying "Somewhere, Somewhere" is not helping yourself.

  6. #6
    Registered User
    Join Date
    10-13-2010
    Location
    Somewhere, Somewhere
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Counting appearence of number just once

    @NBVC: Thanks a lot for precise explanation. It is much more clear now.

    @DonkeyOte: You are right, I did not think of that aspect. I will correct it for the next time.

    Best Regards.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1