+ Reply to Thread
Results 1 to 7 of 7

Derive column value based on multiple criteria

  1. #1
    Registered User
    Join Date
    03-13-2023
    Location
    San Francisco
    MS-Off Ver
    Office 365
    Posts
    3

    Derive column value based on multiple criteria

    I have the following data in excel. I would like to derive the "Action" column for a "Person ID" based on the Y or N indicators in the "Value" and "Month". I have also attached an excel file with this data.

    Person ID Value Month Action
    1 N 1/1/23 1st action
    2 Y 1/1/23
    1 N 2/1/23 2nd action
    2 N 2/1/23 1st action
    2 Y 3/1/23
    3 N 3/1/23 1st action
    2 N 4/1/23 1st action
    3 Y 4/1/23
    4 Y 4/1/23


    For a Person ID, if the value is Y then action should be empty
    If for a Person ID, the value is N then:
    1. Check the last record for that person ID and whether the month is one prior to the current month
    a. If a record exists for the person ID in the prior month, then check the value for that record
    i. If the value is N then action column should be populated with "2nd action"
    ii. If the value is Y then action should be "1st action"
    b. If the person ID is not present in the prior month then action should be "1st action"
    Once a person ID is flagged for "2nd action" that person's record will not be included in the next month

    I have given some examples below:
    1. For Person ID 1
    a. In 1/1/23 since the value is N action is "1st action"
    b. In 2/1/23 value was N and in the prior month (1/1/23) the value was also N, action is "2nd action"
    2. For Person ID 2
    a. In 1/1/23 since value is Y action is empty
    b. In 2/1/23 since value is N and value in the prior month is Y, action is "1st action"
    c. In 3/1/23 since value is Y action is empty
    d. In 4/1/23 since value is N and value in 3/1/23 is Y then "1st action"
    3. For Person ID 3
    a. In 3/1/23 since value is N and there is no record for this ID in the prior month (2/1/23), action is "1st action"
    b. In 4/1/23 since value is Y action is empty

    Date format is mm/dd/yy
    Attached Files Attached Files

  2. #2
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Derive column value based on multiple criteria

    Hello adityatan. Welcome to the forum.

    Cell D8 shows 1st action. This isn't consistent with the rest of the examples. I get 2nd action with my formula.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    What am I missing?
    Dave

  3. #3
    Registered User
    Join Date
    03-13-2023
    Location
    San Francisco
    MS-Off Ver
    Office 365
    Posts
    3

    Re: Derive column value based on multiple criteria

    Thank you for offering help!

    Cell D8 should have 1st action because previous month for that person ID is Y (row 6). Only when there are Ns for two consecutive months for a person ID should the action be 2nd action.

  4. #4
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,587

    Re: Derive column value based on multiple criteria

    In E2 copy down.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Pl note
    Array formula should be confirmed with Ctrl+Shift+Enter keys together.
    If answere is satisfactory press * to add reputation.

  5. #5
    Forum Expert
    Join Date
    04-14-2009
    Location
    Taiwan
    MS-Off Ver
    Excel 2016,2019,O365
    Posts
    2,005

    Re: Derive column value based on multiple criteria

    E2
    =IF(B2="Y","",CHOOSE(SUMPRODUCT((A$2:A2=A2)*($B$2:B2="N")*(DATEDIF($C$2:C2,C2,"YM")<=1)),"1st ","2nd ","3rd ","4th ")&"action")

    copied down.

  6. #6
    Registered User
    Join Date
    03-13-2023
    Location
    San Francisco
    MS-Off Ver
    Office 365
    Posts
    3

    Re: Derive column value based on multiple criteria

    Thank you everyone! windknife - your solution worked!

  7. #7
    Forum Expert
    Join Date
    04-14-2009
    Location
    Taiwan
    MS-Off Ver
    Excel 2016,2019,O365
    Posts
    2,005

    Re: Derive column value based on multiple criteria

    You are welcome.

+ 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. Copy data from one or more column to another multiple column based on criteria
    By paradise2sr in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-08-2022, 03:12 AM
  2. [SOLVED] Capturing Multiple Column’s Data in a Single Column Based on Criteria
    By Rajeshkumar R in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-22-2020, 01:40 PM
  3. Formula to Sum 3 Column Values based on Multiple Criteria for Multiple Rows
    By RMerckling in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 08-19-2016, 07:46 PM
  4. [SOLVED] Find unique cells in column -> Sum another column based on multiple criteria
    By mjoc9 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 08-20-2015, 09:29 AM
  5. [SOLVED] Sum Second Column based on Multiple Criteria from First Column
    By Zimbo in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-09-2015, 10:01 AM
  6. [SOLVED] Please help : Sum of column based on multiple criteria
    By kamalchandra.15 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-06-2013, 02:22 AM
  7. Replies: 7
    Last Post: 06-25-2013, 07:15 PM

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