TEXTJOIN only when the condition is met?
Asked Answered
K

2

12

I tried using TextJoin function with IF in it, but it somehow doesn't seem to work. I think I've written the formula correctly, but it doesn't give the solution I'm attempting to get.

Objective: I want the values from A-column to get printed out only when the values of B-column matches with the value of D-column. The intended outcome should be 1,2,3,6

Does anyone know how can I get done? Did I do something wrong? By the way, I'm using the google spreadsheet.

enter image description here

Kilmer answered 15/8, 2017 at 2:33 Comment(0)
F
4

The if is just giving one result, not a series of them. You need:

=textjoin(" ,",true,arrayformula(if($B$1:$B$20=$D$1,$A$1:$A$20,"")))
Fults answered 15/8, 2017 at 3:17 Comment(0)
A
14

Your formula works you just need to enter it as an array formula, hold ctrl + shift and press enter to make it an array formula. It should look like:

=ArrayFormula(TEXTJOIN(", ",true,if(B1:B6 = D1,A1:A6,"")))  

You could also use the filter function

=TEXTJOIN(", ",true,FILTER(A1:A6,B1:B6 = D1))
Annabelannabela answered 15/8, 2017 at 3:18 Comment(0)
F
4

The if is just giving one result, not a series of them. You need:

=textjoin(" ,",true,arrayformula(if($B$1:$B$20=$D$1,$A$1:$A$20,"")))
Fults answered 15/8, 2017 at 3:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.