Welcome to Excel magic trick number 1,282. Hey, if you want to download this Excel file and follow along, click on the link below the video. Oh, you are not going to believe this video. We need to find multiple lookup values in the first column. Notice if we're looking up invoice number 10001, we have three duplicates and return multiple items from the next column. We need to return multiple items to a single cell. Well, luckily in Excel 2016 there's the TEXTJOIN function. Now, last video, Excel magic trick 1281, I talked all about TEXTJOIN. And the video before that, I talked about how to get the Insider program if you don't have that function. But guess what? Below this Excel magic trick, DRS at YouTube posted a comment. He posted a solution at the Excel message board that solves this problem using TEXTJOIN. Now, let's just go ahead and try this. Equals TEXTJOIN. Well, the delimiter I want to return Bell & Carlo & Quad if it's invoice 10001 with a semicolon. So, I'm going to type double quote, semicolon, space, and double quote, and the key to this problem is this second argument. We want to ignore empty. Yes, it's true or one. And then, comma, the text. Well, somehow I need to eliminate everything that isn't invoice 10001, but I need to eliminate it in this column. So, I need to eliminate all of these. Here's how DRS did it. He used the REPEAT function. Now, the text, well, guess what? I'm going to give it the entire column, comma, and then the number of times. Well, guess what? I need a one, one, one, and nothing down here. So he did an array calculation in parentheses. He said, "Hey, is anything in this column equal to our lookup value?" That will return TRUEs and FALSEs. If I press F9, I really want that to be one, one, which will say repeat this one, one, and I want all these zeros. Control+Z. So I can do any math operation. Now he multiplied by one. I'm going to add zero. Now to see what this evaluates to in the number time, I'm going to hit F9. And there it is: for REPEAT, 1, 1, 1, it means repeat Bell once, Carlo once, Quad once, and all of these means repeat them zero times. Now, this is a function argument array operation right there. That means REPEAT will spit out something for every one of these items in the text argument. Control+Z, close parentheses. If I highlight the entire REPEAT and hit F9, you've got to be kidding me. That is beautiful. Now I have an array of values, the ones I want, and in essence the empties that the TEXTJOIN function can ignore. Control+Z. Because this is a function argument array operation, we're going to have to use the special keystroke Control+Shift+Enter. When we enter that formula, we look up to the formula bar. We verify that the curly brackets are there. Those curly brackets are Excel telling us that it understood that this is an array calculation. You've got to be kidding me. That is simply beautiful. We've been searching for a solution like this where we look up an item, find multiple matches, and return multiple items to a single cell. We've been looking for that solution for years. Now, there's another way we could do this with TEXTJOIN. We still want the same delimiter, semicolon space, and double quote, comma, one for TRUE to ignore empty cells. Instead of REPEAT, I'm simply going to say, hey, if anything in this range right here is equal to 10001, that's an array operation right there, the comparative operator. If I highlight this and hit F9, TRUEs and FALSEs. Those TRUEs and FALSEs can then pick out the right items here. Control+Z. That logical test, because there's an array operation there, will require that we do Control+Shift+Enter. For the value of TRUE, I'm simply going to highlight all those. The TRUEs will pick out those. The FALSEs will do something with those, comma, and the something we want to do is double quote, double quote. That's a zero-length text string that can be interpreted as empty. Close parentheses. Let's just highlight the IF and press F9. And sure enough, we get the same array. Control+Z. Close parenthesis. We have to use Control+Shift+Enter. Verify with the curly brackets up there. We're looking good. That is simply beautiful. TEXTJOIN and two different array operations. I love hanging out on our online Excel team. Thanks to DRS. We'll see you next video.
transcript
excelisfun - Excel Magic Trick 1282: Lookup And Return Multiple Items to a Single Cell: TEXTJOIN Function

Community upload. AI output has not been independently verified.