TEXTJOIN only when the condition is met?

19,905

Solution 1

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,"")))

Solution 2

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))
Share:
19,905

Related videos on Youtube

user234568
Author by

user234568

Updated on September 23, 2022

Comments

  • user234568
    user234568 over 1 year

    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