0

I have data in two columns labeled Email and 01 respectively.

I want to use a query to rearrange the data so that there are 3 columns:

  • Columns 2 and 3 will contain the data from my original two columns if the second column contained the word "cool"
  • Column 1 for each populated row will contain 01

Example Data

  • Source data is in columns B and C
  • desired result is in Columns E, F, G.
  1. The three rows {B6:C7;B10:C10} are included in F6:G8 of the results because they all had "cool" in column C.
  2. The 01 from C5 is repeated in Column E for each populated row in Columns F, G.
B C D E F G
5 Email 01 Email
6 a cool 01 a cool
7 c cool 01 c cool
8 v y 01 f cool
9 g x
10 f cool

How can I perform a query like this?

Example Data

1 Answer 1

0
={"","email","";QUERY(B6:C,"select '" & TRIM($C$5) &"', B, C where C='cool' label '" & TRIM($C$5) &"' ''",0)} 

This formula will literally do what is shown in your screenshot.

Update For second screenshot no need QUERY():

={"","email","";ArrayFormula(SORT(SPLIT(FLATTEN(C5:E5&"🦊"&B6:B10&"🦊"&C6:E10),"🦊"),1,TRUE))} 

Details see Unpivot In Google Sheets With Formulas

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.