+ Reply to Thread
Results 1 to 8 of 8

Unique Values based on Another Column having values >0

Hybrid View

  1. #1
    Registered User
    Join Date
    12-03-2013
    Location
    Coventry
    MS-Off Ver
    Excel 2007
    Posts
    6

    Unique Values based on Another Column having values >0

    Hi,

    I need a quick formula which is saved by a Pivot Table but I would like to have Formula (Maybe Sumproduct?) which counts the number of unique entries in column A but only shows the number if there is a value which is greater than 0 in column B.

    For instance 700 is repeated several times in column A and has 2 records with values greater than 0 in column B. I would like a formula to say that 700 is counted once rather than twice. Hope that makes sense.

    I have attached the file. Basically for Week 1. I have 5 unique Acc_No but only 4 have a value which is greater than 0 in Week 1. I want to return 4.

    Can you help?

    Thanks
    Attached Files Attached Files

  2. #2
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Unique Values based on Another Column having values >0

    Hi,

    For Week 1, this array formula**:

    =SUM(IF(FREQUENCY(IF(B3:B10>0,MATCH(A3:A10,A3:A10,0)),ROW(A3:A10)-MIN(ROW(A3:A10))+1),1))

    Regards


    **Array formulas are not entered in the same way as 'standard' formulas. Instead of pressing just ENTER, you first hold down CTRL and SHIFT, and only then press ENTER. If you've done it correctly, you'll notice Excel puts curly brackets {} around the formula (though do not attempt to manually insert these yourself).
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  3. #3
    Registered User
    Join Date
    12-03-2013
    Location
    Coventry
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Unique Values based on Another Column having values >0

    Thanks XOR LX. If I had blanks which I wanted to exclude from Column A where would I put the <>""?

    Thanks for the quick response.

    James

  4. #4
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Unique Values based on Another Column having values >0

    Try this array formula**:

    =SUM(IF(FREQUENCY(IF(B3:B10>0,A3:A10),A3:A10),1))

    ** array formulas need to be entered using the key
    combination of CTRL,SHIFT,ENTER (not just ENTER).
    Hold down both the CTRL key and the SHIFT key
    then hit ENTER.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  5. #5
    Registered User
    Join Date
    12-03-2013
    Location
    Coventry
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Unique Values based on Another Column having values >0

    Thanks Tony. And If I was to exclude potential blanks would you be able to let me know how I can do that?

    Thanks

    James

  6. #6
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Unique Values based on Another Column having values >0

    If the Acc_No's really are numbers then empty cells should not have any effect on the formula:

    Data Range
    A
    B
    C
    D
    E
    2
    Acc_No
    Week 1
    Week 2
    -----
    Count
    3
    700
    0
    1
    3
    4
    700
    1
    1
    5
    700
    1
    3
    6
    701
    1
    2
    7
    701
    1
    2
    8
    703
    0
    0
    9
    7003
    1
    1
    10
    2
    0
    11


    This array formula entered in E3:

    =SUM(IF(FREQUENCY(IF(B3:B100>0,A3:A100),A3:A100),1))

    ** array formulas need to be entered using the key
    combination of CTRL,SHIFT,ENTER (not just ENTER).
    Hold down both the CTRL key and the SHIFT key
    then hit ENTER.

  7. #7
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Unique Values based on Another Column having values >0

    Ignore my solution. It works, but I was on automatic, and of course your values are already numeric, so Tony's solution is far more economical.

    Regards

  8. #8
    Registered User
    Join Date
    12-03-2013
    Location
    Coventry
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Unique Values based on Another Column having values >0

    I have it thanks both.

    =SUM(IF(FREQUENCY(IF(B3:B11>0,IF(A3:A11="",0,A3:A11)),A3:A11),1))

    Cheers

+ 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. Return number of unique values based on values in other column
    By Medir in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 11-26-2013, 11:17 AM
  2. Replies: 1
    Last Post: 11-16-2013, 05:18 AM
  3. [SOLVED] Filtering and generating new tabs based on Unique values based in column
    By amlan009 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-02-2012, 09:40 PM
  4. Sum values in one column based on unique values in another
    By deepak1987 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-11-2011, 07:37 PM
  5. Count Unique Values based on another column
    By Ineedhelp12 in forum Excel General
    Replies: 2
    Last Post: 07-02-2009, 06:12 PM

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