+ Reply to Thread
Results 1 to 10 of 10

Extract 2 corresponding fields by Date/Month/Year selection

  1. #1
    Forum Contributor
    Join Date
    05-22-2015
    Location
    Malaysia
    MS-Off Ver
    MS365
    Posts
    197

    Extract 2 corresponding fields by Date/Month/Year selection

    Hi,
    Would like to extract the Status Code and Policy name by Date from the raw data (2 worksheet). I have used in the index/match formula as below but it's not working. The data gets repeat.

    Attached is the file for your preview. I am not sure where I missed it. Please advise.
    Last edited by suchetherrah; 12-08-2015 at 07:04 AM.

  2. #2
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Extract 2 corresponding fields by Date/Month/Year selection

    In C12 copied down, this ARRAYED formula

    =IFERROR(INDEX(INDIRECT("FailBk"&$AD$6&"[Policy Name]"), SMALL(IF(YEAR(INDIRECT("FailBk"&$AD$6&"[StartDate]"))=$AD$5, IF(TEXT(INDIRECT("FailBk"&$AD$6&"[StartDate]"),"mmmm")=$AD$4, ROW(INDIRECT("FailBk"&$AD$6&"[StartDate]")))),ROWS($A$1:$A1))),"")

    I do not see a place in your table for "Status Code" but it would be identical with "Status Code" replacing "Policy Name"
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

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

  3. #3
    Forum Contributor
    Join Date
    05-22-2015
    Location
    Malaysia
    MS-Off Ver
    MS365
    Posts
    197

    Re: Extract 2 corresponding fields by Date/Month/Year selection

    Hi,

    The column C12 is working fine. I am refering to column AM and AN. I just need to extract the data for status code and policy name by date selection.

    Result should appear, when user key in the date number, month and year are selected accordingly.
    Status Code Policy Name
    1 Policy A
    1 Policy B
    6 Policy C
    6 Policy C
    1 Policy D
    20 Policy D

    May refer to the attachment to view at Column AM/AN. I have put in the formulas but it's not working.

  4. #4
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Extract 2 corresponding fields by Date/Month/Year selection

    Do you want to extract based on just what is AN9 (month and year) or a combination of AM9 and AN9 (exact date)?

  5. #5
    Forum Contributor
    Join Date
    05-22-2015
    Location
    Malaysia
    MS-Off Ver
    MS365
    Posts
    197

    Re: Extract 2 corresponding fields by Date/Month/Year selection

    AD4: Month
    AD5: Year
    AD6: Location
    AM9: Date (number)

    AN9 is just a display of AD4 and AD5. When select the month/year from AD4 and AD5, AN9 will change automatically.

    2 options to have formulas: either from AD5/AD4/AM9 or AM9/AN9.

  6. #6
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Extract 2 corresponding fields by Date/Month/Year selection

    Okay, coffee is helping

    In AM12 copied down, this Array formula

    =IFERROR(INDEX(INDIRECT("FailBk"&$AD$6&"[Status Code]"), SMALL(IF(INDIRECT("FailBk"&$AD$6&"[StartDate]")=DATEVALUE($AM$9&$AD$4&$AD$5), ROW(INDIRECT("FailBk"&$AD$6&"[StartDate]"))-MIN(ROW(INDIRECT("FailBk"&$AD$6&"[StartDate]")))+1),ROWS($A$1:$A1))),"")

    Similar in AN12

    I had neglected to take into account the data doesn't begin in Row 1
    Attached Files Attached Files

  7. #7
    Forum Contributor
    Join Date
    05-22-2015
    Location
    Malaysia
    MS-Off Ver
    MS365
    Posts
    197

    Re: Extract 2 corresponding fields by Date/Month/Year selection

    Hi,

    Sorry, I am retesting the data and will let you know the outcome.
    Last edited by suchetherrah; 11-24-2015 at 10:40 PM.

  8. #8
    Forum Contributor
    Join Date
    05-22-2015
    Location
    Malaysia
    MS-Off Ver
    MS365
    Posts
    197

    Re: Extract 2 corresponding fields by Date/Month/Year selection

    Hi,

    The formula in the file attached in your post, it's working fine. However, when I copied the formula in a different file which I was working on, it's not working.
    I still couldn't figure out why. Column C12 has to be a unique value as per user's request. Only Column AM and AN having issues.

    Please refer to the attachment I am was trying to copy and I need to know why it's not working.


    I am trying to understanding the formula but I need some clarification:

    1) INDEX(INDIRECT("FailBk"&$AD$6&"[Status Code]") = To display the status code.
    2) SMALL(IF(INDIRECT("FailBk"&$AD$6&"[StartDate]")=DATEVALUE($AM$10&$AD$4&$AD$5) = if 1/9/15 = selection (AD5&AD4&AM9). Why use SMALL function?
    3) ROW(INDIRECT("FailBk"&$AD$6&"[StartDate]")) = When press F9 it shows row 461, 462....which i don't understand
    4) -MIN(ROW(INDIRECT("FailBk"&$AD$6&"[StartDate]")))+1) = why minus 2+1?
    5) ROWS($A$1:$A1))) = row increases.

    Small function is to find the 1st or 2nd smallest number, correct?
    Last edited by suchetherrah; 12-08-2015 at 06:52 AM.

  9. #9
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Extract 2 corresponding fields by Date/Month/Year selection

    Okay, starting with the first issue, the reason it does not work is simply that you have an error in TF3 StartDate (I681). That error carries through to your formula giving you an error which the IFERROR catches. Either fix that cell or fix the formula to catch errors (IFERROR(INT(...),"")

    Next the explaination of the formula. The INDIRECTS just convert TEXT to Ranges of Cells so we'll ignore them. We'll also ignore the IFERROR, and we'll replace some of your cells with the constants. That makes the formula more readable.

    =INDEX('FailBkTB3'![Status Code]), SMALL(IF('FailBkTB3'![StartDate]")=DATEVALUE("1September2015"), ROW('FailBkTB3'![StartDate]))- MIN(ROW('FailBkTB3'![StartDate])))+1),ROWS($A$1:$A1)))

    The IF function creates a new array of row numbers that match 1 Sept 2015. Because your data doesn't begin on row 1, the formula subtracts the first row + 1 (MIN(ROW('FailBkTB3'![StartDate])))+1. For example if the first row that matches is row 6, it would be 6-2+1 or 5 (it is the 5th row of data).

    The SMALL returns a single value for the INDEX to use to return a startdate.

    ROWS($A$1:$A1))) is the second argument in SMALL that, increments as you drag down, 1,2,3...

    Does that help?

  10. #10
    Forum Contributor
    Join Date
    05-22-2015
    Location
    Malaysia
    MS-Off Ver
    MS365
    Posts
    197

    Re: Extract 2 corresponding fields by Date/Month/Year selection

    Im learning something new on INT and the SMALL function.

    Thank you so much for the formula and the explanation, ChemistB.

+ 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. [SOLVED] Extract Day, Month and Year from a text box (user input) date value
    By HeyInKy in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-01-2014, 10:40 PM
  2. [SOLVED] Formual to Extract month and year from sheet name
    By rizmomin in forum Excel Formulas & Functions
    Replies: 13
    Last Post: 07-26-2014, 10:49 PM
  3. Need to convert Month/Date/Year to Year/Month/Date so excel will recognize
    By juliettelam in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-25-2014, 04:17 PM
  4. Replies: 3
    Last Post: 09-04-2013, 10:49 AM
  5. [SOLVED] Set Default Month and Year in a cell for entering date fields
    By kmahesh in forum Excel General
    Replies: 2
    Last Post: 07-26-2013, 11:17 PM
  6. [SOLVED] Extract Year or Month only from a cell with date and time
    By djaurit in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-28-2013, 04:03 PM
  7. [SOLVED] Extract Text from String then Convert to a Date (Month/Year)
    By sgrey24 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-14-2013, 06:11 PM

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