+ Reply to Thread
Results 1 to 10 of 10

How to count distinct values in a column

  1. #1
    Registered User
    Join Date
    01-17-2014
    Location
    Ireland
    MS-Off Ver
    Excel 2007
    Posts
    9

    How to count distinct values in a column

    I have a spreadsheet which contains (see illustration below)
    1. a column called LEAD ID which contains a unique id
    2. a column called WON which signifies if the deal was won/not won (1 = WON, blank = Not Won)

    I can have multiples of the same value in the Won and Unique Id field (see illustration below)

    I would like to create a formula field which returns the summary of the No. of Deals WON
    I need to tie the formula back to the Lead ID and whether or not the WON field contains 1 or not.

    I've tried this formula but it won't work
    (Lead ID is in Column A, WON is in column B)

    =IFERROR(SUM(1/COUNTIF((A:A,A:A) AND(B2=1)),"0")

    LEAD ID WON No. Won (Formula field)
    abc112 0
    abc222 1 .25
    abc222 1 .25
    abc222 1 .25
    abc222 1 .25
    abc333 1 1
    abc444 0



    Any help would be greatly appreciated
    Thanks

  2. #2
    Valued Forum Contributor Sean Thomas's Avatar
    Join Date
    03-25-2012
    Location
    HerneBay, Kent, UK
    MS-Off Ver
    Excel 2007,2016
    Posts
    971

    Re: How to count distinct values in a column

    why dont you just use the filter to show the rows that contain a 1 in the won column?
    Regards
    Sean

    Please add to my reputation if you think i helped
    (click on the star below the post)
    Mark threads as "Solved" if you have your answer
    (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code:
    [code] Your code here [code]
    Please supply a workbook containing example Data:
    It makes its easier to answer your problem & saves time!

  3. #3
    Registered User
    Join Date
    01-17-2014
    Location
    Ireland
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: How to count distinct values in a column

    I'm not using a filter because I want to use the output of the formula in a pivot table which will be used by Sales People

  4. #4
    Valued Forum Contributor Sean Thomas's Avatar
    Join Date
    03-25-2012
    Location
    HerneBay, Kent, UK
    MS-Off Ver
    Excel 2007,2016
    Posts
    971

    Re: How to count distinct values in a column

    do you want a total of cases with 1 or do you want the cases with a 1 copied to another location.

  5. #5
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: How to count distinct values in a column

    Try this formula

    =SUM(IF(FREQUENCY(IF(B2:B100=1,IF(A2:A100<>"",MATCH(A2:A100,A2:A100,0))),ROW(A2:A100)-ROW(A2)+1),1))

    confirmed with CTRL+SHIFT+ENTER

    assumes data from row 2 to row 100 - extend as required, but ideally not with whole columns as that will be slow
    Audere est facere

  6. #6
    Registered User
    Join Date
    01-17-2014
    Location
    Ireland
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: How to count distinct values in a column

    Daddylonglegs: I tried your formula but it does not work for me

    Sean Thomas: Here's an illustration of what I'm trying to achieveWonFormulaField.jpg
    Attached Images Attached Images

  7. #7
    Registered User
    Join Date
    01-17-2014
    Location
    Ireland
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: How to count distinct values in a column

    Daddylonglegs: I tried your formula but it does not work for me

    Sean Thomas: Here's an illustration of what I'm trying to achieve WonFormulaField.jpg

  8. #8
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: How to count distinct values in a column

    Seems I misunderstood your question

    Try this formula in C2 copied down

    =IF(B2=1,1/COUNTIFS(A:A,A2,B:B,1),"")

  9. #9
    Valued Forum Contributor Sean Thomas's Avatar
    Join Date
    03-25-2012
    Location
    HerneBay, Kent, UK
    MS-Off Ver
    Excel 2007,2016
    Posts
    971

    Re: How to count distinct values in a column

    nice one DD, you beat me to it.

  10. #10
    Registered User
    Join Date
    01-17-2014
    Location
    Ireland
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: How to count distinct values in a column

    Thank DD that worked a treat

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 7
    Last Post: 01-29-2015, 10:14 AM
  2. Replies: 10
    Last Post: 07-16-2013, 03:19 PM
  3. [SOLVED] Count Conditional Distinct Values
    By Gos-C in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-10-2013, 05:41 AM
  4. [SOLVED] Count Distinct Values
    By djfatboyfats in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 11-20-2012, 07:39 AM
  5. Count Distinct Values?
    By bill_morgan in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 04-26-2005, 10:06 PM

Tags for this Thread

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