Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I combine cells from different columns on the same row to cells on different rows in the same column?

I have data coming in a certain way, but I need it automatically converted into a different layout for a specific chart in Google Data Studio.

Basically, I want to go from this

Date    Apple   Banana   Cherry

Jan 1   500     800      2000
Jan 2   800     920      2878
Jan 3   1700    1850     3000

To this:

Date     Type     Amount

Jan 1    Apple    500
Jan 1    Banana   800 
Jan 1    Cherry   2000
Jan 2    Apple    800
Jan 2    Banana   920
Jan 2    Cherry   2878
Jan 3    Apple    1700
Jan 3    Banana   1850
Jan 3    Cherry   3000

I can't think of a solution (I'm relatively new at this). I'm hoping someone might be able to point me in the right direction. Thanks in advance for any help I can get!

like image 666
David Folkerson Avatar asked Jan 26 '23 12:01

David Folkerson


1 Answers

ultimate 720° freedom with no limits:

=ARRAYFORMULA({"Date", "Type", "Amount"; 
 SPLIT(TRANSPOSE(SPLIT(TRANSPOSE(QUERY(TRANSPOSE(QUERY(TRANSPOSE(
 IF(B2:Z<>"", A2:A&"♠"&B1:1&"♠"&B2:Z&"♦", )), , 500000)), , 500000)), "♦")), "♠")})

0

like image 96
player0 Avatar answered Jan 29 '23 03:01

player0