Home > Back-end >  Insert Row in between query result or using google app script
Insert Row in between query result or using google app script

Time:01-27

So I have a set of data here, example below

enter image description here

and I am trying to get a result similar to this

enter image description here

I am thinking of using query, and I found this query formula:

=query({Sheet1!$A$1:$A;Sheet1!$B$1:$B;Sheet1!$C$1:$C},"select * where Col1 <>'' ",0)

but this only applies in transforming wide to long dataset

Is there a way to do it using query? or even an app script?

CodePudding user response:

What you can do is to add a set of values with only the first two words. For that you can use:

=INDEX(SPLIT(UNIQUE(IFNA(REGEXEXTRACT(A:A,"(.  . ) "))&"¿¿"),"¿",1,0))

enter image description here

PS: the two ¿¿ are for adding the extra columns. If you actually have more columns, add more ¿ signs -- (you don't need to do this step, I'm just showing you the process)

Then, with the query:

=QUERY({A:C;INDEX(SPLIT(UNIQUE(IFNA(REGEXEXTRACT(A:A,"(.  . ) "))&"¿¿"),"¿",1,0))},"Select * where Col1 is not null order by Col1")

You'll get something like this in the right:

enter image description here

Then, with conditional formatting you can get something like this:

=($I1<>"")*($J1="")*($K1="")

PS: adapt the actual columns

enter image description here

  • Related