Last matching Value in multiple Columns

Emre06

New Member
Joined
Sep 27, 2023
Messages
19
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
Hello, i have 2 Columns containing guards's names. ( I tried to use "maxifs" function but it is working only for one column ) My Question is: I need formula to find "Last Date" of "John Fizz" in "Beach"?

Kitap1 (version 1).xlsb
ABCD
1DateGuard 1Guard 2Location
21.02.2023Mike RogersRomeo LoiLobby
32.02.2023John FizzTaric BenBeach
43.02.2023Alan DuskLora IanHotel
54.02.2023Clark KentJohn FizzBeach
Sayfa1
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Thank you very much Sir! Tried and worked :) If you don't mind, could you explain how it works ?
 
Upvote 0
Excel Formula:
(XMATCH("John FizzBeach",B:B&D:D,0,-1)

This bit is looking for the row index from the bottom up for the string "John FizzBeach" when columns B and D join together. (Guard 1)

Excel Formula:
(XMATCH("John FizzBeach",C:C&D:D,0,-1)
Same thing for this bit but looking in columns C and D (Guard 2)

At this point, you have a row index for Guard 1 and Guard 2, but you want the latest so we apply the MAX().

Then use INDEX() to return the date from Column A, with the row index.
 
Upvote 1
Thank you very much.

(XMATCH("John FizzBeach",C:C&D:D,0,-1)

İs it possible to use cells for"JohnFizzBeach" like
(XMATCH(B3&D3,C:C&D:D,0,-1)
 
Upvote 0
Thank you it worked. I tried to use same formula for others but there is a problem. If I use same formula for "Mike Rogers" ( Hes only been as First Guard not second) formula gives error ?
 
Upvote 0
@Emre06 - you also need to aware that the XMatch option supplied gets the "last matching" value in the table (that is what the "-1" at the end of the function does - tells it to look from the bottom up). This means your date column needs to be sorted in ascending order.

Here is another option:
Note:
* is AND logic ie both need to be true
+ is OR logic ie one or more need to be true

Excel Formula:
=MAX(
            FILTER( $A$2:$A$10,
                          (($B$2:$B$10=G2)*($D$2:$D$10=H2))
                          +(($C$2:$C$10=G2)*($D$2:$D$10=H2))
                          )
           )
 
Upvote 1
Thank you it worked. I tried to use same formula for others but there is a problem. If I use same formula for "Mike Rogers" ( Hes only been as First Guard not second) formula gives error ?

This will work when that happens but @Alex Blakenburg has a shorter solution.

Excel Formula:
=LET(guard1,XMATCH(C2&D2,B:B&D:D,0,-1),guard2,XMATCH(C2&D2,C:C&D:D,0,-1),IFERROR(INDEX(A:A,MAX(IF(ISNUMBER(guard1),guard1,-1),IF(ISNUMBER(guard2),guard2,-1))),"Not found"))
 
Upvote 1
@BigBeachBananas Thank you very much !

@Emre06 - you also need to aware that the XMatch option supplied gets the "last matching" value in the table (that is what the "-1" at the end of the function does - tells it to look from the bottom up). This means your date column needs to be sorted in ascending order.

Here is another option:
Note:
* is AND logic ie both need to be true
+ is OR logic ie one or more need to be true

Excel Formula:
=MAX(
            FILTER( $A$2:$A$10,
                          (($B$2:$B$10=G2)*($D$2:$D$10=H2))
                          +(($C$2:$C$10=G2)*($D$2:$D$10=H2))
                          )
           )
Thank you very much for you kind help Sir. Sorry But Firstly cannot copy code, I think spaces are giving me problem. And G2 value and H2 value is empty I suppose ? I couldnt manage to use that :(
 
Upvote 0

Forum statistics

Threads
1,215,706
Messages
6,126,334
Members
449,309
Latest member
kevinsucher

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top