+ Reply to Thread
Results 1 to 15 of 15

Filter data based on columns, display unique row data

  1. #1
    Forum Contributor
    Join Date
    10-29-2004
    Posts
    291

    Filter data based on columns, display unique row data

    I have a long list of data like this.

    PHP Code: 
    ColumnB    ColumnC        ColumnD     ColumnE 
    Name        Work Order     Date        Job Commission 
    Alex        23816
    -1        5/6/13      $45.24 
    John        21083
    -1        5/6/13      $22.20 
    John        23643
    -1        5/6/13      $76.08 
    Alex        23929
    -1        5/7/13      $45.00 
    John        23965
    -1        5/7/13      $41.55 
    Debr        23983
    -1        5/7/13      $30.00 
    John        23984
    -1        5/8/13      $49.20 
    Alex        24011
    -1        5/8/13      $30.00 
    Debr        24030
    -1        5/8/13      $30.00 
    Mike        21397
    -1        5/9/13      $107.52 
    Sean        24098
    -1        5/9/13      $102.00 
    I need a way to search an entire column and display the rows with the matching cell (in this case "Alex"). As you can see column C, D and E all common unique information.

    PHP Code: 
    ColumnB    ColumnC        ColumnD     ColumnE 
    Alex        23816
    -1        5/6/13      $45.24 
    Alex        23929
    -1        5/7/13      $45.00 
    Alex        24011
    -1        5/8/13      $30.00 
    What's the best way to achieve this?
    Last edited by djarcadian; 05-16-2013 at 09:56 PM. Reason: Oops the subject

  2. #2
    Valued Forum Contributor Lemice's Avatar
    Join Date
    04-13-2013
    Location
    Somewhere.
    MS-Off Ver
    Excel 2016
    Posts
    696

    Re: Filter data based on columns, display unique row data

    Hello,

    The easy way would be creating a helper column using COUNTIF that distinguish a row being unique or not, and then you can filter on that column. Of course you can always add a condition on it to make the COUNTIF to only count when the value in Column B matches what you are looking for (In this case, "Alex").

    The rough method should be using Array formula to return all unique rows, though if your file has a large number of data, this method is not really encouraged.
    (copy pasta from Ford)
    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

    Regards,
    Lem

  3. #3
    Forum Contributor
    Join Date
    10-29-2004
    Posts
    291

    Re: Filter data based on columns, display unique row data

    Thanks but I'm still confused. I tried Googling the COUNTIF but I'm still not sure how that will give me the results I need. Here's a screenshot of my raw data.

    data.png

    And here's how I want to use it.

    excel.png

    As you can see my project workbook displays all the work order data for the John Smith. It pulls data from every row in the raw data with the name John Smith in column A.

    Sorry if I'm not understanding how the Countif could accomplish this.

  4. #4
    Valued Forum Contributor Lemice's Avatar
    Join Date
    04-13-2013
    Location
    Somewhere.
    MS-Off Ver
    Excel 2016
    Posts
    696

    Re: Filter data based on columns, display unique row data

    My proposed idea involves the use of COUNTIF to count the number of rows that will have the exact same data in all four column B, C, D and E at the same time. If the result is 1, the row should be unique, otherwise it is duplicated.

    Can you provide a small sample file with dummy data? It will be much easier for others to help you also.

  5. #5
    Forum Contributor
    Join Date
    10-29-2004
    Posts
    291

    Re: Filter data based on columns, display unique row data

    Here you go.
    Attached Files Attached Files

  6. #6
    Valued Forum Contributor Lemice's Avatar
    Join Date
    04-13-2013
    Location
    Somewhere.
    MS-Off Ver
    Excel 2016
    Posts
    696

    Re: Filter data based on columns, display unique row data

    This is turning out different than I thought.

    You can try using a filter, and by choosing the name on column A, no mater which rows has that name, it will show itself in a neat table, like the attached file.

    However, if you want a more advanced methods, you can try the Array method - just change the name in G1 and see the list update itself. Note that you will have to drag the formula down as far as you see a lot of "blank".

    Also note that for the sake of testing, I have messed your table up.
    Attached Files Attached Files

  7. #7
    Forum Contributor
    Join Date
    10-29-2004
    Posts
    291

    Re: Filter data based on columns, display unique row data

    Another dumb question. The array formula seems to be my best option but how do I cut-and-paste it from your example workbook to my own?

  8. #8
    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,933

    Re: Filter data based on columns, display unique row data

    Try this...

    enter smith, John in E2
    Then in f2, copied down, use this regular formula...
    =IFERROR(INDEX(OFFSET(INDEX($B$2:$B$71, MATCH($E$2,$A$2:$A$71, 0)),,, COUNTIF($A$2:$A$71, $E$2), ), ROW(A1)), "")
    for the subsequent columns, copy that across, and change the $B$2:$B$71 to c, d etc
    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

  9. #9
    Valued Forum Contributor Lemice's Avatar
    Join Date
    04-13-2013
    Location
    Somewhere.
    MS-Off Ver
    Excel 2016
    Posts
    696

    Re: Filter data based on columns, display unique row data

    I suggest you try the solution from FDibbins, that is a really good one.

    About the Array method, because they are Array formula, after you paste them, you will have to click on the formula bar, then hold Ctrl-Shift and hit Enter (Confirm with CSE). Afterward, if the formula is being wrapped inside a { } like in the sample, you did it right.

    All you have to do is copy the formula on A2, paste it on your real workbook, make it Array (wrapped inside { } ), drag it to D2, then Select all A2 to D2, drag it down as far as you see blank.

  10. #10
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Filter data based on columns, display unique row data

    Have you tried a Pivot Table? A find code will do as well.

  11. #11
    Forum Contributor
    Join Date
    10-29-2004
    Posts
    291

    Re: Filter data based on columns, display unique row data

    Quote Originally Posted by FDibbins View Post
    Try this...

    enter smith, John in E2
    Then in f2, copied down, use this regular formula...
    =IFERROR(INDEX(OFFSET(INDEX($B$2:$B$71, MATCH($E$2,$A$2:$A$71, 0)),,, COUNTIF($A$2:$A$71, $E$2), ), ROW(A1)), "")
    for the subsequent columns, copy that across, and change the $B$2:$B$71 to c, d etc
    Can you explain what purpose the ROW(A1) serves at the end of this code?

  12. #12
    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,933

    Re: Filter data based on columns, display unique row data

    ROW(A1) is 1 of te ways to make a formula increment certain arguments.

    ROW(A1) = 1
    ROW(A2) = 2
    etc

  13. #13
    Forum Contributor
    Join Date
    10-29-2004
    Posts
    291

    Re: Filter data based on columns, display unique row data

    Okay, I think I get. Now here's another problem I'm experiencing. I've divided my data and formulas into different sheets. Now, when my data is sorted by name the formula works fine but when the data is mixed up it becomes a mess. I've attached an example sheet to show what I mean.

    If you click on the other sheet and sort it by name it works fine but if the data is sorted by any other column and the names aren't in order then the formula falls apart and displays a mixture of names.

    Is there a way to fix this?
    Attached Files Attached Files

  14. #14
    Forum Contributor
    Join Date
    10-29-2004
    Posts
    291

    Re: Filter data based on columns, display unique row data

    I couldn't find a solution but I think it figured out WHY it's doing it. The formula is counting the number of instances that the specific name is mentioned in a column BUT it's using that count number and displaying all names after the first instances that the name appears in the row. That works well enough for me if my data is sorted by name but given my needs it's too likely to cause problems at some point.

  15. #15
    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,933

    Re: Filter data based on columns, display unique row data

    Lets try a different approach.

    On sheet1 V2, use this, copied down...
    =A2&COUNTIF($A$2:A2,A2)

    Then on sheet3, similar to Daily, put the name you want in B1, and in C1:E1, the same headings as Daily. In C2, copied down, use this...
    =IFERROR(INDEX(Sheet1!F:F,MATCH(Sheet3!$B$1&ROW($A1),Sheet1!$V:$V,0),1),"")
    Change F:F to match the other columns you want to extract

    If you make the headings on each sheet identical, you can then use this instead, and copy it across...
    =IFERROR(INDEX(Sheet1!$A:$U,MATCH(Sheet3!$B$1&ROW($A1),Sheet1!$V:$V,0),MATCH(Sheet3!C$1,Sheet1!$A$1:$U$1,0)),"")

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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