I have a data sheet of emails and some boolean (checkbox) data points for each:
I would like to construct a comma-separated list of emails, given a filter constructed on-the-fly via two additional rows of checkboxes that determine:
TRUE
);NOT
of the column should be used).In the below example, row 3 and row 8 pass the filter condition, as NOT(B3)*C3*E3=TRUE
(and likewise with row 8):
I was able to accomplish this for a single column, but I have a lot of these checkbox data columns (and may add/remove some in the future), so I'd ideally like a solution that works for an arbitrary number of columns. My current attempt:
=TEXTJOIN(",", TRUE, FILTER(A2:A8, NOT(B$10:E$10)+XOR(B2:E8,B$11:E$11)))
complains about a mis-matched FILTER
range.
Is there a good way to solve this with one command for an arbitrary number of columns?
Based on your given data (assuming that the data in cell A13
is your desired output), I suggest using this formula:
=LET(a, HSTACK(A1:A8, FILTER(B1:E8,B10:E10)),
b, HSTACK(A10:A11, FILTER(B10:E11,B10:E10)),
c, MAP(CHOOSEROWS(b,1),CHOOSEROWS(b,2),LAMBDA(x,y,IFERROR(XOR(x,y)))),
d, JOIN(",",HSTACK(FILTER(c,c<>""))),
e, HSTACK(CHOOSECOLS(a,1),BYROW(CHOOSECOLS(a,SEQUENCE(1,COLUMNS(a)-1,2,1)),LAMBDA(z,JOIN(",",z)))),
JOIN(",",INDEX(FILTER(e,CHOOSECOLS(e,2)=d),,1)))
To simplify the process, I split the data into array a
(email data) and array b
(use and invert options data). If your data expands, you will only need to adjust the range for variables a
and b
.
Data 1 | Data 2 | Data 3 | Data 4 | |
---|---|---|---|---|
email@email.com | TRUE | TRUE | TRUE | TRUE |
me@other.email.com | FALSE | TRUE | TRUE | TRUE |
someone@this.email.com | TRUE | TRUE | TRUE | TRUE |
yesno@again.com | FALSE | FALSE | FALSE | FALSE |
memyselfandi@info.org | TRUE | TRUE | TRUE | TRUE |
youyourselfandthou@english.org | FALSE | FALSE | TRUE | TRUE |
foultarnished@omen.king.gov | FALSE | TRUE | FALSE | TRUE |
USE | TRUE | TRUE | FALSE | TRUE |
INVERT | TRUE | FALSE | FALSE | FALSE |
me@other.email.com,foultarnished@omen.king.gov