+ Reply to Thread
Results 1 to 28 of 28

Edit the formula to make index&match include 3 criteria

  1. #1
    Forum Contributor
    Join Date
    02-24-2015
    Location
    Egypt
    MS-Off Ver
    Office 365 ProPlus
    Posts
    769

    Edit the formula to make index&match include 3 criteria

    Hello Everybody
    Explaination:"The formula in ""F ""column should calculate the working hours (last out-first in) based on 2 critera:
    1- the same HR ""Employee code""
    2- the same date
    Please Login or Register  to view this content.
    The demand:I want the index formula to take first in.I tried to apply this in column "G" but I got error
    Reason:I want to apply the third criteria because the old formula with 2 criteria gets incorrect results
    Please Login or Register  to view this content.
    please find the attachmnt
    Waiting your support
    Attached Files Attached Files
    Last edited by leprince2007; 12-11-2016 at 04:58 PM.

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,608

    Re: Edit the formula to make index&match include 3 criteria

    Sorry for off-topic interjection:

    Although there is no official rule regarding this behavior, we request that wherever possible both the question AND the answer be provided in substantive detail here within the thread. An attached workbook is an excellent aid for posing a question and offering a solution, but solely doing that with no in thread explanation makes it difficult for researchers to understand or consider the Q & A of this thread without downloading what may be a pointless doc to them, if they can do that at all. Doing that also hides the content from search engines so others may never benefit from this.

    I'm sure you understand, and we look forward to seeing you post your formulas/macros in your posts for the searching benefit of all.

    Thanks again for all your hard work here!
    Ben Van Johnson

  3. #3
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Edit the formula to make index&match include 3 criteria

    Unless there are instances where the two cells in question are not the same HR number and the Out time always follows the In time then you could simplify the F19 formula to

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    If you do want to build in a check for the same HR then just preface the formula with an
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  4. #4
    Forum Contributor
    Join Date
    02-24-2015
    Location
    Egypt
    MS-Off Ver
    Office 365 ProPlus
    Posts
    769

    Re: Edit the formula to make index&match include 3 criteria

    Quote Originally Posted by Richard Buttrey View Post
    Unless there are instances where the two cells in question are not the same HR number and the Out time always follows the In time then you could simplify the F19 formula to

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    If you do want to build in a check for the same HR then just preface the formula with an
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    See 1st post I clarified my demand:
    I want to correct the formula in "G" column

  5. #5
    Valued Forum Contributor
    Join Date
    05-08-2015
    Location
    Uvalde, TX
    MS-Off Ver
    2010
    Posts
    720

    Re: Edit the formula to make index&match include 3 criteria

    Hi,

    I was looking to develop a formula for your needs, but I feel that your data is flawed.
    For example: rows 17, 18 and 19 are the same date with a "Temp. OUT" before there is a "Temp. IN"
    There are two "Temp. OUT" times. One is 8:17 and other is 8:16.
    The "Temp. IN" time is 23:26.

    Why is the "Temp. IN" time much later than either of the two "Temp. OUT" times on the same day?

  6. #6
    Forum Contributor
    Join Date
    02-24-2015
    Location
    Egypt
    MS-Off Ver
    Office 365 ProPlus
    Posts
    769

    Re: Edit the formula to make index&match include 3 criteria

    Quote Originally Posted by southward View Post
    Hi,

    I was looking to develop a formula for your needs, but I feel that your data is flawed.
    For example: rows 17, 18 and 19 are the same date with a "Temp. OUT" before there is a "Temp. IN"
    There are two "Temp. OUT" times. One is 8:17 and other is 8:16.
    The "Temp. IN" time is 23:26.

    Why is the "Temp. IN" time much later than either of the two "Temp. OUT" times on the same day?
    Every employee works 3 shifts:
    1st shift 8:00 to 16:00
    2nd shift 16:00 to 24:00
    3rd shift 24:00 to 8:00
    The formula should calculte (last out-first in) in order to get working hours
    I hope you understand

  7. #7
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Edit the formula to make index&match include 3 criteria

    Quote Originally Posted by leprince2007 View Post
    See 1st post I clarified my demand:
    I want to correct the formula in "G" column
    Well put the formula I gave you in G19 instead of F19!

  8. #8
    Forum Contributor
    Join Date
    02-24-2015
    Location
    Egypt
    MS-Off Ver
    Office 365 ProPlus
    Posts
    769

    Re: Edit the formula to make index&match include 3 criteria

    I want to build a formula for the whole file that contains attendance of 150 employees with more than 6000 rows
    I want to correct the error in formula in column "G"
    Please your support

  9. #9
    Forum Contributor
    Join Date
    02-24-2015
    Location
    Egypt
    MS-Off Ver
    Office 365 ProPlus
    Posts
    769

    Re: Edit the formula to make index&match include 3 criteria

    Up........................................Up.......................................................UP

  10. #10
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,178

    Re: Edit the formula to make index&match include 3 criteria

    As per Richard's reply (#3 AND #7):

    In G11 and copy down

    =IF(AND(A11=A10,E11="Temp. OUT"),D11-D10+IF(D11<D10,1,0),"")
    Attached Files Attached Files

  11. #11
    Forum Contributor
    Join Date
    02-24-2015
    Location
    Egypt
    MS-Off Ver
    Office 365 ProPlus
    Posts
    769

    Re: Edit the formula to make index&match include 3 criteria

    Quote Originally Posted by JohnTopley View Post
    As per Richard's reply (#3 AND #7):

    In G11 and copy down

    =IF(AND(A11=A10,E11="Temp. OUT"),D11-D10+IF(D11<D10,1,0),"")
    Thank you for your answer, but your formula doesn`t give correct answers:
    Your formula doesn`t calculate this (last out-first in).And the formula should also take into consideration the following:
    1- there are duplicate "ins" and "outs" >>>>I want The formula to calculate (last out-first in)
    2-There is "in" without "out" or vice versa >>>>I want the formula to give an error in this case
    Find the attachement,I applied your formula for another piece of data
    I hope you help me
    Attached Files Attached Files

  12. #12
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Edit the formula to make index&match include 3 criteria

    Quote Originally Posted by leprince2007 View Post
    Thank you for your answer, but your formula doesn`t give correct answers:
    I think you'll find it does.
    You are ignoring the seconds contained in the column D times.

    For instance D21 is 15:52:54 and D22 is 23:43:11. That's a difference of 7 hours and 17 seconds. If you format G22 to show hh:mm:ss you'll see it correctly shows 7:50:17. Maybe you need to incorporate a rounding - or maybe not. It all depends what you want to SEE.

  13. #13
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Edit the formula to make index&match include 3 criteria

    Quote Originally Posted by leprince2007 View Post
    Thank you for your answer, but your formula doesn`t give correct answers:
    I think you'll find it does.
    You are ignoring the seconds contained in the column D times.

    For instance D21 is 15:52:54 and D22 is 23:43:11. That's a difference of 7 hours and 17 seconds. If you format G22 to show hh:mm:ss you'll see it correctly shows 7:50:17. Maybe you need to incorporate a rounding - or maybe not. It all depends what you want to SEE.

  14. #14
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Edit the formula to make index&match include 3 criteria

    Quote Originally Posted by leprince2007 View Post
    Thank you for your answer, but your formula doesn`t give correct answers:
    I think you'll find it does.
    You are ignoring the seconds contained in the column D times.

    For instance D21 is 15:52:54 and D22 is 23:43:11. That's a difference of 7 hours and 17 seconds. If you format G22 to show hh:mm:ss you'll see it correctly shows 7:50:17. Maybe you need to incorporate a rounding - or maybe not. It all depends what you want to SEE.

  15. #15
    Forum Contributor
    Join Date
    02-24-2015
    Location
    Egypt
    MS-Off Ver
    Office 365 ProPlus
    Posts
    769

    Re: Edit the formula to make index&match include 3 criteria

    Quote Originally Posted by Richard Buttrey View Post
    I think you'll find it does.
    You are ignoring the seconds contained in the column D times.

    For instance D21 is 15:52:54 and D22 is 23:43:11. That's a difference of 7 hours and 17 seconds. If you format G22 to show hh:mm:ss you'll see it correctly shows 7:50:17. Maybe you need to incorporate a rounding - or maybe not. It all depends what you want to SEE.
    First :No, I want the formula to give the exact hours,minutes and seconds
    Second:You ignored that my formula should calculate this (last out-first in)
    Download the attachment in post 11# to see what I`am talking about (as I changed the data)
    please your support
    Last edited by leprince2007; 12-12-2016 at 06:42 AM.

  16. #16
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Edit the formula to make index&match include 3 criteria

    Quote Originally Posted by leprince2007 View Post
    Thank you for your answer, but your formula doesn`t give correct answers:
    I think you'll find it does.
    You are ignoring the seconds contained in the column D times.

    For instance D21 is 15:52:54 and D22 is 23:43:11. That's a difference of 7 hours and 17 seconds. If you format G22 to show hh:mm:ss you'll see it correctly shows 7:50:17. Maybe you need to incorporate a rounding - or maybe not. It all depends what you want to SEE.

  17. #17
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Edit the formula to make index&match include 3 criteria

    Quote Originally Posted by leprince2007 View Post
    First :No, I want the formula to give the exact hours,minutes and seconds
    Second:You ignored that my formula should calculate this (last out-first in)
    Download the attachment in post 11# to see what I`am talking about (as I changed the data)
    please your support
    Re 1. Then format G22 as h:mm:ss

    Re 2. You ignored the caveat in my original where I mentioned the In/Out pairs. Don't be surprised if you change your data and show us a different set if the formula doesn't continue to work. It's important when you give an example that it accurately reflects all your permutations of data otherwise we all waste our time.

    One approach is an array formula in say G22
    ..sorry, have to attach an image, Sucuri isn't allowing me to enter all the formula

    formula.JPG
    Last edited by Richard Buttrey; 12-12-2016 at 07:41 AM.

  18. #18
    Forum Contributor
    Join Date
    02-24-2015
    Location
    Egypt
    MS-Off Ver
    Office 365 ProPlus
    Posts
    769

    Re: Edit the formula to make index&match include 3 criteria

    I`am sorry for that.

    In brief I want to add this criteria:
    Please Login or Register  to view this content.
    to this formula
    Please Login or Register  to view this content.
    In order to make the formula bring first "in"
    please help me

  19. #19
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Edit the formula to make index&match include 3 criteria

    Quote Originally Posted by leprince2007 View Post
    I`am sorry for that.

    In brief I want to add this criteria:
    Please Login or Register  to view this content.
    to this formula
    Please Login or Register  to view this content.
    In order to make the formula bring first "in"
    please help me
    Have you actually tried the formula I gave you in #17 which I believe gives you the results you expect?

  20. #20
    Forum Contributor
    Join Date
    02-24-2015
    Location
    Egypt
    MS-Off Ver
    Office 365 ProPlus
    Posts
    769

    Re: Edit the formula to make index&match include 3 criteria

    Thank you for your support,But i want the result in last "out" only,not in every "out".
    As by doing this, The working hours of every day is doubled and this is wrong.
    Please your support
    Last edited by leprince2007; 12-12-2016 at 09:10 AM.

  21. #21
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Edit the formula to make index&match include 3 criteria

    Hi

    I can now that Ali has mentioned the Sucuri limitation on the chevrons

    Formula: copy to clipboard
    Please Login or Register  to view this content.

  22. #22
    Forum Contributor
    Join Date
    02-24-2015
    Location
    Egypt
    MS-Off Ver
    Office 365 ProPlus
    Posts
    769

    Re: Edit the formula to make index&match include 3 criteria

    Thank you for your support,But i want the result in last "out" only,not in every "out".
    As by doing this, The working hours of every day is doubled and this is wrong.
    Please your support

  23. #23
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Edit the formula to make index&match include 3 criteria

    Hi,

    Slight variation. Maybe

    Formula: copy to clipboard
    Please Login or Register  to view this content.

  24. #24
    Forum Contributor
    Join Date
    02-24-2015
    Location
    Egypt
    MS-Off Ver
    Office 365 ProPlus
    Posts
    769

    Re: Edit the formula to make index&match include 3 criteria

    1-In G42,G43 the formula should give me "0" like the old formula" or an error ,as they have "in" without "out" in 18-19/Nov days
    2-In G46 the result is 2 seconds and this is wrong,In this case the formula should bring first in but it brought first match which is "out" in "D44"
    please your support

  25. #25
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,178

    Re: Edit the formula to make index&match include 3 criteria

    I suggest you add a "Helper" column (say F)

    =TRIM(RIGHT($E11,3))

    Then Custom SORT by

    Column A

    Column C

    Column F

    Column D

    Your formula will then work.
    Attached Files Attached Files

  26. #26
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Edit the formula to make index&match include 3 criteria

    Quote Originally Posted by JohnTopley View Post
    I suggest you add a "Helper" column (say F)
    Good point John. I was coming to the same conclusion myself

  27. #27
    Forum Contributor
    Join Date
    02-24-2015
    Location
    Egypt
    MS-Off Ver
    Office 365 ProPlus
    Posts
    769

    Re: Edit the formula to make index&match include 3 criteria

    Quote Originally Posted by JohnTopley View Post
    I suggest you add a "Helper" column (say F)

    =TRIM(RIGHT($E11,3))

    Then Custom SORT by

    Column A

    Column C

    Column F

    Column D

    Your formula will then work.
    Great idea! well done

  28. #28
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,178

    Re: Edit the formula to make index&match include 3 criteria

    Thank you the feedback and rep. Glad it's sorted.

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

+ 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. Rank formula to include Index Match formula
    By MakkyD in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 05-24-2016, 11:28 AM
  2. Replies: 2
    Last Post: 01-22-2016, 06:30 AM
  3. Replies: 2
    Last Post: 09-27-2014, 04:34 PM
  4. Replies: 6
    Last Post: 04-30-2014, 02:42 AM
  5. [SOLVED] Formula whit INDEX and MATCH. I try to make this formula to result.
    By Anka in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-28-2012, 06:26 PM
  6. Index match formula tweeking to include sumif
    By MZing81 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-28-2012, 01:14 PM
  7. Replies: 14
    Last Post: 04-27-2010, 01:20 AM

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