Forum Discussion
Question XLOOKUP finding the next match row if blank
Hi, Question:
I have a data set which using XLOOKUP returns an email address for a customer number.
ON the email data set, there are multiple emails for each customer number.
How can I return the next email address using XLOOKUP if there are blanks in this email set?
Any clues?!
13 Replies
- PeterBartholomew1Silver Contributor
A couple of thoughts. An alternative to searching for concatenated conditions is to simply strike out the customers that do not have declared email from consideration. If there isn't an entry with an email, you could always relent and use the 'if not found' parameter to repeat the search to return such data that may exist.
= XLOOKUP( @selected, IF(email<>"", customer), email:phone ) or = XLOOKUP( @selected, IF(email<>"", customer), email:phone, XLOOKUP( @selected, customer, email:phone ) )
- aussieCCopper Contributor
Thanks PeterBartholomew1 - very helpful! Cheers
- SergeiBaklanDiamond Contributor
- KSolakCopper Contributor
Hi Sergei, I'm trying to use the Xlookup method so that I can reverse the search order. It works in Excel, but not Google Sheets. I'm guessing it has to do with the way arrays are handled. Any thoughts?
- SergeiBaklanDiamond Contributor
I'm not familiar with Google Sheets, but it looks like last-to-first works in it
- leanneypantsCopper Contributor
SergeiBaklan amazing, i used the second with the XLOOKUP and it worked.... i tried a ton of others including filters and what not. this worked!
- SergeiBaklanDiamond Contributor
leanneypants glad it helped, thank you for the feedback
- R_DunbarCopper Contributor
Thanks Sergei this has worked great for me also!
On the xlookup what does the &1 mean also &-- In the formula?
Cheers
Rich
- SergeiBaklanDiamond Contributor
Rich, glad to help.
Here (C2:C7<>"") returns an array with TRUE or FALSE. Double dash converts them to 1 or 0 accordingly, thus --(C2:C7<>"") returns an array with 1 for non-empty cells and 0 for empty ones.
By & we concatenate B2:B7 with this array (for example ="a" & "b" returns "ab"). Resulting array will be {"f11", "f2", "f21", "f3",...}.
=D3&1 returns text "f21". Finally we try to find this text in above array and return related value from C2:C7.