+ Reply to Thread
Results 1 to 6 of 6

INDEX MATCH IF Between Two Dates - Comparing Two Tables

  1. #1
    Registered User
    Join Date
    05-21-2015
    Location
    London
    MS-Off Ver
    2016
    Posts
    3

    INDEX MATCH IF Between Two Dates - Comparing Two Tables

    Suppose you have two tables laid out like this. How can you query each row on Table 2 against Table 1 and return a MATCH result?

    I've tried =MATCH(1,([@Employee]=Table1[Employee])*([@[Leave Type]]=Table1[Leave Type])*OR(([@[Leave Date]]=Table1[Leave Start]),[@[Leave Date]]=Table1[Leave Finish],AND([@[Leave Date]]>Table1[Leave Start],[@[Leave Date]]<Table1[Leave Finish])),0) but the AND section doesn't return TRUE for Table 2 row 5 even though 1/3/2015 is greater than 1/2/2015 and less than 1/4/2015.

    See attachment for prepared data.

    What am I missing here? Is there a better way?

    Table 1
    Employee Leave Type Leave Start Leave Finish
    A Sick 1/1/2015
    A Annual 1/2/2015
    B Sick 1/1/2015
    B Sick 1/2/2015 1/4/2015
    B Sick 1/5/2015 1/9/2015
    B Sick 1/11/2015
    C Annual 1/5/2015 1/9/2015
    C Flex 1/11/2015 1/15/2015

    Table 2
    Employee Leave Type Leave Date
    A Sick 1/1/2015
    A Annual 1/2/2015
    B Sick 1/1/2015
    B Sick 1/2/2015
    B Sick 1/3/2015
    B Sick 1/4/2015
    B Sick 1/5/2015
    B Sick 1/6/2015
    B Sick 1/7/2015
    B Sick 1/8/2015
    B Sick 1/9/2015
    B Sick 1/11/2015
    C Annual 1/5/2015
    C Annual 1/6/2015
    C Annual 1/7/2015
    C Annual 1/8/2015
    C Annual 1/9/2015
    C Flex 1/11/2015
    C Flex 1/12/2015
    C Flex 1/13/2015
    C Flex 1/14/2015
    C Flex 1/15/2015
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    09-17-2014
    Location
    UK
    MS-Off Ver
    2007
    Posts
    117

    Re: INDEX MATCH IF Between Two Dates - Comparing Two Tables

    Attachment appears to be missing - if you could upload it I'll take a look.

    Are you wanting to know if an entry from table 1 is within a date range of an entry in table 2?
    What's the exact criteria/logic you want to apply?

  3. #3
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,914

    Re: INDEX MATCH IF Between Two Dates - Comparing Two Tables

    =SUMPRODUCT(MAX((Table1[Employee]=Table2[[#This Row],[Employee]])*(Table1[Leave Type]=Table2[[#This Row],[Leave Type]])*(Table1[Leave Start]<=Table2[[#This Row],[Leave Date]])*((Table1[Leave Finish]+(Table1[Leave Finish]=0)*Table1[Leave Start])>=Table2[[#This Row],[Leave Date]])*(ROW(Table1[Leave Start])-MIN(ROW(Table1[Leave Type]))+1)))
    Please Login or Register  to view this content.
    TRY THE ABOVE FORMULA
    Samba

    Say thanks to those who have helped you by clicking Add Reputation star.

  4. #4
    Registered User
    Join Date
    05-21-2015
    Location
    London
    MS-Off Ver
    2016
    Posts
    3

    Re: INDEX MATCH IF Between Two Dates - Comparing Two Tables

    Hi,

    Sorry the attachment is available now.

    Essentially, I want to see if all entries in Table 2 exist in Table 1.

    So my logic is: IF
    Table 2 Employee = Table 1 Employee AND
    Table 2 Leave Type = Table 2 Leave Type AND
    (
    Table 2 Leave Date = Table 1 Leave Start OR
    Table 2 Leave Date = Table 1 Leave Finish OR
    (
    Table 2 Leave Date > Table 1 Leave Start AND
    Table 2 Leave Date < Table 2 Leave Finish
    )
    )
    IS TRUE or FALSE.

    Thanks for helping.

  5. #5
    Registered User
    Join Date
    05-21-2015
    Location
    London
    MS-Off Ver
    2016
    Posts
    3

    Re: INDEX MATCH IF Between Two Dates - Comparing Two Tables

    Quote Originally Posted by nflsales View Post
    =SUMPRODUCT(MAX((Table1[Employee]=Table2[[#This Row],[Employee]])*(Table1[Leave Type]=Table2[[#This Row],[Leave Type]])*(Table1[Leave Start]<=Table2[[#This Row],[Leave Date]])*((Table1[Leave Finish]+(Table1[Leave Finish]=0)*Table1[Leave Start])>=Table2[[#This Row],[Leave Date]])*(ROW(Table1[Leave Start])-MIN(ROW(Table1[Leave Type]))+1)))
    Please Login or Register  to view this content.
    TRY THE ABOVE FORMULA
    Wow. I don't know how you got that so quick! But huge thanks!

    I had the impression SUMPRODUCT doesn't work with text.

  6. #6
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,914

    Re: INDEX MATCH IF Between Two Dates - Comparing Two Tables

    You are welcome and thanks for your feedback

+ 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. Index and Match - comparing cells based on max price?
    By ffxdean in forum Excel General
    Replies: 1
    Last Post: 05-11-2015, 05:48 PM
  2. Replies: 5
    Last Post: 03-13-2015, 08:40 AM
  3. Index Match Match Formula DOESN'T WORK WITH TABLES/TABLE NAMES ??
    By Underling in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-04-2014, 09:01 PM
  4. [SOLVED] Comparing list using INDEX MATCH etc. in an array-formula
    By Saturn in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 04-14-2013, 09:02 AM
  5. [SOLVED] Comparing a list of dates to check they match
    By koltregaskes in forum Excel General
    Replies: 14
    Last Post: 05-28-2012, 06:51 AM

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