+ Reply to Thread
Results 1 to 4 of 4

Creating new field with conditional values based on existing data

  1. #1
    Registered User
    Join Date
    05-30-2012
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    16

    Creating new field with conditional values based on existing data

    Hi everyone, I was hoping someone could help me with the following:

    I have a large set of data for patients. One of the fields is for Patient-ID(########), another field is for Case-ID(########), and another field is for Date(DD-MMM-YY).
    Each Patient-ID can occur more than once, each Case-ID can occur more than once, and each Date can occur more than once.

    I need to create a new field for which the possible values are 1, 2, 3, 4, .... I want the default value in this field to be 1 for each row, and I want the value 2 to be displayed for any entries where the Case-ID for a given Patient-ID is different from the first Case-ID for that Patient-ID. And I want the value 3 to be displayed for any entries where the Case-ID for a given Patient-ID is different from the first and second unique Case-IDs for that Patient-ID.

    For example, if for Patient-00384759 I have:

    __Patient-ID__|__Case-ID__|__Date__

    __00384759__|_00239485_ |_26-Jan-12__
    __00384759__|_00239485_ |_13-Feb-12__
    __00384759__|_00239485_ |_25-Feb-12__
    __00384759__|_01392345_ |_30-Mar-12__
    __00384759__|_01392345_ |_09-Apr-12__
    __00384759__|_00897273_ |_27-Jun-12__


    then I want to create a new field such that the data looks like:

    __Patient-ID__|__Case-ID__|___Date____ |__Admission__

    __00384759__|_00239485_ |_26-Jan-12__|_____1_____
    __00384759__|_00239485_ |_13-Feb-12__|_____1_____
    __00384759__|_00239485_ |_25-Feb-12__|_____1_____
    __00384759__|_01392345_ |_30-Mar-12__|_____2_____
    __00384759__|_01392345_ |_09-Apr-12__|_____2_____
    __00384759__|_00897273_ |_27-Jun-12__|_____3_____



    Does anyone know how I'd be able to make the code for this new field? Any help is much appreciated!

    -Niraj

  2. #2
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Creating new field with conditional values based on existing data

    Niraj,

    Attached is an example workbook based on the criteria you described. In cell D2 and copied down is this formula:
    Please Login or Register  to view this content.
    Does that work for you?
    Attached Files Attached Files
    Hope that helps,
    ~tigeravatar

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  3. #3
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Creating new field with conditional values based on existing data

    After a bit of tweaking, realized formula can be shortened to:
    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    05-30-2012
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    16

    Re: Creating new field with conditional values based on existing data

    Thanks tigeravatar, that worked perfectly! Big help! :D

+ 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