+ Reply to Thread
Results 1 to 15 of 15

counting unique value only in a filtering table help

  1. #1
    Registered User
    Join Date
    10-25-2014
    Location
    canada
    MS-Off Ver
    2007
    Posts
    16

    counting unique value only in a filtering table help

    Hi,

    I need to count number of employee on each project we have. problem is some employee will work on different job in the same day.

    I want to be able to filter: job 1 and return lets say 12 emp. then filter job 2 only and return 10 emp. but if I select all job as my filter it would return lets say 15 emp. as some of them worked on both job that day.

    I think I would need a helper column to show 1 if unique and 0 for the duplicated value. Problem is every formula I tried will not work with the filtering option.

    lets say I filter only job #2 then every emp. should have a 1 but some will have a 0 because they were also in job #1.


    also if I can get this formula working would it also consider it in a pivot table?

    see attached example
    Attached Files Attached Files
    Last edited by pattheriault; 01-18-2015 at 09:27 PM.

  2. #2
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,463

    Re: counting unique value only in a filtering table help

    In L8

    =COUNTIF($B$3:$B$21,K8)

    In O8:

    =COUNTIFS($A$3:$A$21,$O$5,$B$3:$B$21,N8)

    Fill down.
    Quang PT

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

    Re: counting unique value only in a filtering table help

    Try this array formula**:

    =SUM(IF(FREQUENCY(IF(SUBTOTAL(3,OFFSET(A3,ROW(A3:A21)-ROW(A3),0,1)),MATCH(C3:C21,C3:C21,0)),ROW(A3:A21)-ROW(A3)+1),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.

  4. #4
    Registered User
    Join Date
    10-25-2014
    Location
    canada
    MS-Off Ver
    2007
    Posts
    16

    Re: counting unique value only in a filtering table help

    these give me the total but wont work with the pivot table. im not sure if the pivot can actually work the way I want it or not.

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

    Re: counting unique value only in a filtering table help

    I never use PTs.

    Let me see if I can get a PT advocate to look at this.

  6. #6
    Registered User
    Join Date
    10-25-2014
    Location
    canada
    MS-Off Ver
    2007
    Posts
    16

    Re: counting unique value only in a filtering table help

    That would be appreciated. I think that if I could get the helper column to return me 1 and 0 if duplicated or not and having these 1 and 0 able to change has I filter other column it could possibly work.

  7. #7
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: counting unique value only in a filtering table help

    The attached workbook doesn't include an actual pivot table, just a regular table with a filter applied. I could work on that, but it may be wasted effort since it's not a real pivot table, no real pivot tools.

    Can you post a workbook with real starting data so we can pivot it correctly? You can include a manual mockup of the results you're wanting from that raw data.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  8. #8
    Registered User
    Join Date
    10-25-2014
    Location
    canada
    MS-Off Ver
    2007
    Posts
    16

    Re: counting unique value only in a filtering table help

    there is a pivot table in that file. The other table were just added in to show what result I would like to see. The grand total in the pivot table is right using the helper column.

    But Helper column doesn't change to apply different filter.
    Attached Files Attached Files

  9. #9
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: counting unique value only in a filtering table help

    Quote Originally Posted by pattheriault View Post
    But Helper column doesn't change to apply different filter.
    For example?

  10. #10
    Registered User
    Join Date
    10-25-2014
    Location
    canada
    MS-Off Ver
    2007
    Posts
    16

    Re: counting unique value only in a filtering table help

    I need a formula in the helper column to return 1 the first time an item is listed an 0 for every other time it is duplicated.

    I need that formula to be able to change result as I filter my table. (nothing to do with the pivot table.

    lets say I have a guy that worked on 2 jobs, If I have all jobs selected I only want to count him once (return 1 and then zero) if I filter to show only 1 jobs and choose the second job that same guys will show as 0. because he was counted in the first job. I need to be able to have the formula return 1 instead of 0 when I filter to not see the first job he was on.

  11. #11
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: counting unique value only in a filtering table help

    So, forgetting the filter, you want a formula that will show 1 the first time it shows in VISIBLE rows, and a 0 if it shows again in VISIBLE rows. If the VISIBLE rows change, you want the formula results to change so the first VISIBLE row for the guy will show 1 even if it's not the same row as it was before? If yes, I'm thinking you will need a SUBTOTAL trick of some kind.

  12. #12
    Registered User
    Join Date
    10-25-2014
    Location
    canada
    MS-Off Ver
    2007
    Posts
    16

    Re: counting unique value only in a filtering table help

    that is exactly what I want!

    Yes I agree it will need a subtotal in there somewhere but I am not sure how to go with this one.

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

    Re: counting unique value only in a filtering table help

    Hi.

    Bit confused. So can you clarify whether or not this is to form part of a Pivot Table?

    Regards
    Click * below if this answer helped

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

  14. #14
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Cool Re: counting unique value only in a filtering table help

    Here is my way...
    I have used named ranges and Frequency function

    Named Ranges by selecting any cell in first row
    DataArray
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    BinArray
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Formula in G3
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    I have explained this frequency construction in Post No. 39 in the link below:-
    http://www.excelforum.com/excel-form...ml#post3958135

    Check the attached file:-
    Example__1.xlsx
    Regards,
    Vikas Gautam
    Excel-buzz.blogspot.com

    Excel is not a matter of Experience, its a matter of Application.

    Say Thanks, Click * Add Reputation

  15. #15
    Registered User
    Join Date
    10-25-2014
    Location
    canada
    MS-Off Ver
    2007
    Posts
    16

    Re: counting unique value only in a filtering table help

    Quote Originally Posted by XOR LX View Post
    Hi.

    Bit confused. So can you clarify whether or not this is to form part of a Pivot Table?

    Regards
    Yes once I have the helper column working I plan to use it in a pivot table. Not sure if it's gonna work or not in there tho.

+ 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. Counting unique items from different columns using pivot table
    By F16Stevie in forum Excel Charting & Pivots
    Replies: 8
    Last Post: 06-14-2013, 04:13 AM
  2. [SOLVED] counting unique values in col A against unique value in column B
    By greyscale in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-08-2013, 08:43 AM
  3. Counting # Of Unique Items In A 12 Month Period (Table)
    By unpluggedmusic in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 01-13-2013, 09:39 AM
  4. Replies: 0
    Last Post: 11-16-2011, 12:39 PM
  5. Replies: 6
    Last Post: 10-18-2011, 07:34 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