0
votes

Need some help running a Query in Big Query from Google Sheets.

How the data is (at GoogleSheets):

_____|_____| Product1 | Product2 | Product3| ...
     |Spec1|  Value   |  Value   |  Value  | ...
G1   |Spec2|  Value   |  Value   |  Value  | ...
_____|Spec3|  Value   |  Value   |  Value  | ...
     |Spec4|  Value   |  Value   |  Value  | ...
G2   |Spec5|  Value   |  Value   |  Value  | ...
_____|Spec6|  Value   |  Value   |  Value  | ...
.
.
.

where G1, G2 [...] are a group of spec's (not really useful for the query I want). where Spec1, Spec2 [...] are characteristics of the products. where Value's are the qualification of each spec.

How I'd like it to be at the query:

Product | Spec 1 | Spec 2 | Spec 3 | Spec 4 | Spec 5 | Spec 6 | ...
Product1|  Value |  Value |  Value |  Value |  Value |  Value | ...
Product2|  Value |  Value |  Value |  Value |  Value |  Value | ...
Product3|  Value |  Value |  Value |  Value |  Value |  Value | ...
Product4|  Value |  Value |  Value |  Value |  Value |  Value | ...
Product5|  Value |  Value |  Value |  Value |  Value |  Value | ...
Product6|  Value |  Value |  Value |  Value |  Value |  Value | ...
.
.
.

Is there a way to do that? Seems like an newbie question because it really is. (LOL) Any suggestions are welcome.

2

2 Answers

0
votes

Formula for you

=TRANSPOSE({data range})

Example

enter image description here

Function References

0
votes

Consider below approach

select * from (
  select * from your_table
  unpivot (Value for Product in (Product1, Product2, Product3))
)
pivot (any_value(Value) for Spec in ('Spec1','Spec2','Spec3','Spec4','Spec5','Spec6'))    

if applied to sample data as in your question

enter image description here

output is

enter image description here