+ Reply to Thread
Results 1 to 6 of 6

Thread: Formula to find records based on other values in group

  1. #1
    Registered User
    Join Date
    09-09-2011
    Location
    Wisconsin
    MS-Off Ver
    Excel 2010
    Posts
    33

    Formula to find records based on other values in group

    Allow me to explain through example:

    Here is some sample data:

    ID----------GROUP----------STATUS
    043----------38---------------Closed
    048----------38---------------Open
    075----------42---------------Closed
    075----------42---------------Closed
    088----------53---------------Open
    023----------53---------------Closed
    015----------53---------------Open

    Basically, I only want to retrieve records for a Group if the Group contains at least one Open and at least one Closed for the status column.

    I'd be grateful if anyone had any ideas on how to write such a formula.
    Last edited by hk106; 01-09-2012 at 01:49 PM.

  2. #2
    Forum Guru NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    32,636

    Re: Having trouble with this formula

    Assuming your data is in Sheet1, starting with headers at A1...

    Then in D2 enter formula:

    =IF(AND(COUNTIFS($B$2:$B$8,B2,$C$2:$C$8,"Closed"),COUNTIFS($B$2:$B$8,B2,$C$2:$C$8,"Open")),COUNT($D$ 1:$D1)+1,"")

    copied down

    and in E2 enter:

    =MAX(D:D)

    then in Sheet2, A2 use formula to retrieve the relevant info:

    =IF(ROWS($A$2:$A2)>Sheet1!$E$2,"",INDEX(Sheet1!A:A,MATCH(ROWS($A$2:$A2),Sheet1!$D:$D)))

    copied down and across 3 columns
    Attached Files Attached Files
    Microsoft MVP - Excel

    Where there is a will there are many ways. Pick One!


    Please read the Forum Rules

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

    Preferred Charities: Lupus Canada and Sick Kids Foundation.
    Feel Free to Donate if you want to, for the assistance you received today.

  3. #3
    Registered User
    Join Date
    09-09-2011
    Location
    Wisconsin
    MS-Off Ver
    Excel 2010
    Posts
    33

    Re: Having trouble with this formula

    NBVC, thanks for the response.

    After reviewing the recordset, I'm realizing there are more possible values for the STATUS field then just "Open" and "Closed." I am still checking to ensure that there is at least one value with "Open" per Group, but how could I tweak your formula to check to ensure that there is at least one value that is not "Open per Group?

  4. #4
    Forum Guru NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    32,636

    Re: Formula to find records based on other values in group

    So you want to extract all records if there is at least one status that is not "OPEN"?

    If yes, try changing formula in D2 of Sheet1 to:

    =IF(COUNTIFS($B$2:$B$8,B2,$C$2:$C$8,"<>Open"),COUNT($D$1:$D1)+1,"")

    copied down
    Microsoft MVP - Excel

    Where there is a will there are many ways. Pick One!


    Please read the Forum Rules

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

    Preferred Charities: Lupus Canada and Sick Kids Foundation.
    Feel Free to Donate if you want to, for the assistance you received today.

  5. #5
    Registered User
    Join Date
    09-09-2011
    Location
    Wisconsin
    MS-Off Ver
    Excel 2010
    Posts
    33

    Re: Formula to find records based on other values in group

    Quote Originally Posted by NBVC View Post
    So you want to extract all records if there is at least one status that is not "OPEN"?
    Almost. It's both.

    I apologize for my lack of clarity. I'm hoping for a formula that will identify the records whose groups contain
    a) at least one "Open" record
    b) at least one record that is not "Open"

    I assume it's a matter of combining the formulas you've provided, I'm just not sure how to construct it.

    Thank you for you effort on this.

  6. #6
    Forum Guru NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    32,636

    Re: Formula to find records based on other values in group

    Then:

    =IF(AND(COUNTIFS($B$2:$B$8,B2,$C$2:$C$8,"Open"),COUNTIFS($B$2:$B$8,B2,$C$2:$C$8,"<>Open")), COUNT($D$1:$D1)+1,"")
    Microsoft MVP - Excel

    Where there is a will there are many ways. Pick One!


    Please read the Forum Rules

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

    Preferred Charities: Lupus Canada and Sick Kids Foundation.
    Feel Free to Donate if you want to, for the assistance you received today.

+ 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.2.0