简体   繁体   中英

Google Sheets - Flattening a table into two columns, but returning results based on varying conditions

My table has data similar to the following: Raw Data

I am flattening the data into two columns using the following:

=INDEX(QUERY(SPLIT(FLATTEN(IF(SheetName!B1:D=TRUE, SheetName!B1:D1&"×"&SheetName!A1:A,)), "×"),"where Col2 is not null order by Col1 asc"))

The result is depicted here: Flattened Data

However, I also need to return within the "flattened data" columns the following:

1@email.com | 1@email.com

2@email.com | 2@email.com

3@email.com | 3@email.com

In other words, I need to return SheetName!A1:A&"×"&SheetName!A1:A for each email address contained in the email column (Column A), in addition to the other data that is being flattened into the column. I have tried variations using IF/IFS statements, wildcards (not permitted within IFs), etc. However, I am now seeking some help after striking out many times. Thanks for any help you can offer!

Update Example spreadsheet with sample data and current vs. desired results (formula in cell H2): https://docs.google.com/spreadsheets/d/1wq9kR4UqYeWsqSCbnkGGHbR-TIHTfaBb_ixGk41X2cs/edit?usp=sharing

perhaps:

=INDEX(QUERY(SPLIT(FLATTEN(IF(SheetName!B1:D=TRUE, 
 SheetName!B1:D1&"×"&SheetName!A1:A&"×"&SheetName!A1:A,)), "×"),
 "where Col3 is not null order by Col1 asc"))

在此处输入图像描述


update:

=INDEX({QUERY(SPLIT(FLATTEN(
 IF(Sheet1!B1:F=TRUE, Sheet1!B1:F1&"×"&Sheet1!A1:A,)), "×"),
 "where Col2 is not null order by Col1"); 
 TEXT(UNIQUE(FILTER(A2:A, A2:A<>"")), {"@", "@"})})

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM