+ Reply to Thread
Results 1 to 12 of 12

Count Unique Values with Partial Match one column exact match another column

  1. #1
    Forum Contributor
    Join Date
    08-14-2006
    Location
    USA
    MS-Off Ver
    2019
    Posts
    686

    Count Unique Values with Partial Match one column exact match another column

    XL 2013

    This connection is made with Data > Connections > Microsoft Query.
    (I can’t use the Power Query the connection fails.)

    This formula returns the Count of Females with LaborCode begins with N during the specified Check Date.

    SUMPRODUCT(--(Table_Query_from_XX[CheckDate]=RptCkDt),
    --(LEFT(Table_Query_from_XX[LaborDistributionCode],1)="N"),
    --(Table_Query_from_XX[***]="F")
    )


    The problem is an employee check may be cut, cancelled and recut, thereby counting that employee three times instead of once.

    How can I count only once occurrence of each female employee (Table_Query_from_XX[EmployeeNumber] ) while maintaining the functionality of LaborCode begins with N?

    (Can't seen to get it from a Pivot Table either.)

  2. #2
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: Count Unique Values with Partial Match one column exact match another column

    I recommend uploading a small representative sample of your data along with the desired results (which you can enter manually) based on that data.

    To upload an Excel workbook, follow these steps:
    1) Click on "Go Advanced"
    2) Click on "Manage Attachments"
    3) Click on "Choose File"
    4) Choose your file and click on "Open"
    5) Click on "Upload"
    6) Click on "Close this window"

  3. #3
    Forum Contributor
    Join Date
    08-14-2006
    Location
    USA
    MS-Off Ver
    2019
    Posts
    686

    Re: Count Unique Values with Partial Match one column exact match another column

    see attached

  4. #4
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Count Unique Values with Partial Match one column exact match another column

    Have a look at using countifs() instead.
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  5. #5
    Forum Contributor
    Join Date
    08-14-2006
    Location
    USA
    MS-Off Ver
    2019
    Posts
    686

    Re: Count Unique Values with Partial Match one column exact match another column

    I don't want to use a helper column because:

    1. I can't seem to readily add a calculated field to the MS Query
    2. I don't really want to create another table full of calculated columns to analyze the data in the query.

    BTW this formula is not in the query table it's on another sheet for the user to view.

  6. #6
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: Count Unique Values with Partial Match one column exact match another column

    Try this:

    Please Login or Register  to view this content.
    Ctrl Shift Enter

  7. #7
    Forum Contributor
    Join Date
    08-14-2006
    Location
    USA
    MS-Off Ver
    2019
    Posts
    686

    Re: Count Unique Values with Partial Match one column exact match another column

    My EmployeeNumber is actually TEXT in the query results so it's failing.

    I apologize my sample data did not reflect that.

  8. #8
    Forum Expert José Augusto's Avatar
    Join Date
    10-29-2014
    Location
    Portugal
    MS-Off Ver
    2013-2016
    Posts
    3,329

    Re: Count Unique Values with Partial Match one column exact match another column

    Hi

    Try this formula (I suppose EmployeeNumber in D9:D20)
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    08-14-2006
    Location
    USA
    MS-Off Ver
    2019
    Posts
    686

    Re: Count Unique Values with Partial Match one column exact match another column

    Quote Originally Posted by José Augusto View Post
    Hi

    Try this formula (I suppose EmployeeNumber in D9:D20)
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    This does not return the correct result nor does in consider
    LEFT(Table_Query_from_XX[LaborDistributionCode],1)="N")

  10. #10
    Forum Expert José Augusto's Avatar
    Join Date
    10-29-2014
    Location
    Portugal
    MS-Off Ver
    2013-2016
    Posts
    3,329

    Re: Count Unique Values with Partial Match one column exact match another column

    Try this array formula

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

  11. #11
    Forum Contributor
    Join Date
    08-14-2006
    Location
    USA
    MS-Off Ver
    2019
    Posts
    686

    Re: Count Unique Values with Partial Match one column exact match another column

    Solved modified 63falcondude solution by adding *1 after the [EmployeeNumber]s:

    =SUM(--(FREQUENCY(IF((Table_Query_from_XX[CheckDate]=RptCkDt)*(Table_Query_from_XX[***]="F")*(LEFT(Table_Query_from_XX[LaborDistributionCode])="N"),Table_Query_from_XX[EmployeeNumber]*1),Table_Query_from_XX[EmployeeNumber]*1)>0))



    PS. how funny, the forum changed my Db fields 3 letter word for Gender to 3 asterisks [***]!

  12. #12
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,647

    Re: Count Unique Values with Partial Match one column exact match another column

    It's a taboo word around here. It thinks of it in terms of procreation, rather than gender, and we don't talk about that here.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

+ 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: 4
    Last Post: 04-02-2019, 12:22 PM
  2. [SOLVED] Amending an IF formula from an exact match to partial match
    By pauldaddyadams in forum Excel General
    Replies: 2
    Last Post: 03-02-2017, 05:11 PM
  3. [SOLVED] Count number of unique values in Column A that match a term in Column B
    By frsaxon in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-29-2016, 07:22 AM
  4. To Sort exact and partial exact match for a single column.
    By Jagdev in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-22-2014, 05:08 AM
  5. Replies: 4
    Last Post: 02-19-2013, 02:19 PM
  6. Replies: 5
    Last Post: 02-24-2011, 11:26 AM
  7. Replies: 4
    Last Post: 12-14-2009, 03:21 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