+ Reply to Thread
Results 1 to 10 of 10

Extract unique values based on either of two conditions in another column

  1. #1
    Registered User
    Join Date
    12-11-2011
    Location
    Los Angeles, CA
    MS-Off Ver
    Excel Pro Plus 2019
    Posts
    67

    Extract unique values based on either of two conditions in another column

    Hi,

    We have a six (6) column table: Date-Txn ID-FirstName-LastName-Plan-Amount
    In report columns (preferably on a different tab), we have this array formula to extract unique Txn ID's from the table.

    Please Login or Register  to view this content.
    How can I use additional criteria to extract unique Txn ID' that have a plan named "5-Pay" or "10-Pay" and in a separate column count the number of transactions in the table for each Txn ID.

    Also, on the Expected results tab have a list of the unique Tnx ID's, name it belongs to, and number of payments made, including the initial payment and date of last payment received.

    I have attached a sample file with raw data, my formulas and what result is expected.

    I appreciate taking the time to read my post.

    RJ
    Attached Files Attached Files

  2. #2
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,025

    Re: Extract unique values based on either of two conditions in another column

    1. What is your CURRENT Excel version?

    2. Formula or VBA?
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  3. #3
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,192

    Re: Extract unique values based on either of two conditions in another column

    Try

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


    CSE entry
    Last edited by JohnTopley; 10-02-2022 at 05:22 AM.
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  4. #4
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,025

    Re: Extract unique values based on either of two conditions in another column

    Heres a formula version. Each shade = different formula. Here's the one (in C2) that does the hard work. NONE are array formulae.

    =IFERROR(INDEX(Data!B:B,AGGREGATE(15,6,ROW(Data!$B$2:$B$76)/((Data!$B$2:$B$76<>"")*(ISNUMBER(SEARCH("Pay Plan",Data!$E$2:$E$76)))*(COUNTIF(C$1:C1, Data!$B$2:$B$76)=0)),1)),"")
    Attached Files Attached Files

  5. #5
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: Extract unique values based on either of two conditions in another column

    Full vba solution,

    updates Data!G2:G3 & Expected Results each time you select Expected Results sheet from other worksheet.
    1) to Extpected Result sheet code module
    Please Login or Register  to view this content.
    2) to a Standard code module
    Please Login or Register  to view this content.
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    12-11-2011
    Location
    Los Angeles, CA
    MS-Off Ver
    Excel Pro Plus 2019
    Posts
    67

    Thumbs up Re: Extract unique values based on either of two conditions in another column

    Thank you Glenn for this perfect solution, especially all formulas are without CSE and I can make further changes after I study how to use the aggregate command.

    I just noticed one thing, the formulas work perfect on the "Expected Results" sheet but not on the "Data" sheet, the first result show up on all rows in column J. My intention was to use the formula on the Data sheet, but I can live with using it on the Expected Results sheet, which I'll change to "Report".

    Also when I changed the absolute references for column B and column E in the formula, in column J of the Data sheet,

    Please Login or Register  to view this content.
    I got duplicate results, so I guess I must keep using absolute references and keep changing the range every time I get more data rows.

    Again I appreciate your time and expertise, I'll mark this thread solved after you reply to this reply.
    Last edited by RJK; 10-02-2022 at 12:51 PM.

  7. #7
    Registered User
    Join Date
    12-11-2011
    Location
    Los Angeles, CA
    MS-Off Ver
    Excel Pro Plus 2019
    Posts
    67

    Re: Extract unique values based on either of two conditions in another column

    Thank you Jindon,

    Your vba code worked too, but, it will take me a longer time to study it and learn the nuances of the code and how to change it, if needed, for additional tasks and learn from it.

  8. #8
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,025

    Re: Extract unique values based on either of two conditions in another column

    1. I have put the results into the desired sheet.

    2. There are times when using whole-column references is a good idea. There are times when it is NOT. This is one of the second type of times. But, you cna used dynamic named ranges. These autoadjust the ranges to suit your date. CTRL-F3 to view/edit.

    They all are like this one:

    =Data!$B$2:INDEX(Data!$B:$B,MATCH("Zzzz",Data!$B:$B))

    The formulae then change a bit to look like this:

    =IFERROR(INDEX(B:B,AGGREGATE(15,6,ROW(ID)/((ID<>"")*(ISNUMBER(SEARCH("Pay Plan",Plan)))*(COUNTIF(K$1:K1,ID)=0)),1)),"")

    You're welcome.



    It would be very nice if you were to just click the Add Reputation button at the foot of any of the posts of members who helped you reach a solution.

    Finally, if that takes care of your original question, please click on "Thread Tools" from the menu link (just above the first post in the thread) and mark this thread as SOLVED.
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    12-11-2011
    Location
    Los Angeles, CA
    MS-Off Ver
    Excel Pro Plus 2019
    Posts
    67

    Re: Extract unique values based on either of two conditions in another column

    Thank you Glenn again for your help.

    The formula in the new file is exactly same as what I entered in the Data sheet, yet yours works and mine did not, I guess I don't have the magic touch

    I'll test with CTRL-F3 later.

  10. #10
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,025

    Re: Extract unique values based on either of two conditions in another column

    Did you set up ALL of the Named Ranges???

+ 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. Extract Unique Values From Across Column P2:R10
    By bjnockle in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-07-2020, 10:07 AM
  2. Count unique values based on two conditions
    By thomasuponor in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-25-2020, 09:13 AM
  3. [SOLVED] Excel formula to extract unique values based on conditions
    By gideone in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-17-2019, 10:44 AM
  4. [SOLVED] Count unique values from a column with conditions
    By Fullspeeduws in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-30-2018, 08:19 AM
  5. [SOLVED] Extract values based if conditions met
    By bjnockle in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 08-06-2017, 06:06 PM
  6. Replies: 2
    Last Post: 08-19-2015, 10:22 AM

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