Google Sheet one column "fixed, rest tranpose - google-sheets

I am trying to make the following without using google-script.
I have this sheet (A):
And I want to get Sheet (B) "auto-updated", every time the sheet (A) changes.
What I am trying to get on sheet (B):
Thank you very much in advance.

Thanks for sharing a sheet. This formula is in A2 on a new tab called MK.Help.
=ARRAYFORMULA(VLOOKUP(SEQUENCE(COUNTA('sheet 1'!A2:A)*4;1;0)/4+2;{ROW('sheet 1'!A2:A)\'sheet 1'!A2:A\'sheet 1'!B2:E\IF(ROW('sheet 1'!A2:A);'sheet 1'!B1:E1)};MOD(SEQUENCE(COUNTA('sheet 1'!A2:A)*4;1;0);4)*{0\1\1}+{2\3+4\3}))
This solution is designed for 4 columns. In your case, there are no empty cells, but if there were, you would use a query around the solution like this:
=ARRAYFORMULA(QUERY(VLOOKUP(SEQUENCE(COUNTA('sheet 1'!A2:A)*4;1;0)/4+2;{ROW('sheet 1'!A2:A)\'sheet 1'!A2:A\'sheet 1'!B2:E\IF(ROW('sheet 1'!A2:A);'sheet 1'!B1:E1)};MOD(SEQUENCE(COUNTA('sheet 1'!A2:A)*4;1;0);4)*{0\1\1}+{2\3+4\3});"where Col2 is not null"))
It can also be built for an unknown number of columns. If that's something you need, let me know.
I call this a "retabulation" problem and it comes up often enough that i tried to create a lesson for my method. Here's a link to that lesson. It's a bit of a work in progress, but maybe it will help.
https://docs.google.com/spreadsheets/d/1EV_iziWtrTrkPdwY0FI2l0lzTFt-IRQHCOg1punnN5c/edit#gid=0

here the formula:
= arrayformula(
{
"Date","Country","Value";
split
(
transpose
(
split
(
textjoin
(
":",false,filter(A2:A&","&B1:D1&"," & B2:D,A2:A<>"")
)
,":",true,false
)
)
,",",true,false
)
}
)

Related

Match table with database based on input and return multiple rows - index Match / vlookup?

I'll try to explain this the best i can.
I've got a database that hardly ever changes on 1 tab and i've got a dynamic table on other tab which is generated with data from the web.
I am trying to set up a formula that changes the outcome based on the colors i selected.
i can't link the original sheet but i tried to put together a small test sheet to make it more clear
https://docs.google.com/spreadsheets/d/114DxB1vqdH9MHuE5jr-iR1WfUdjMk4sY0dtvkCN80Y8/edit?usp=sharing
The linked sheet discribes what i want to get.
i tried allot of formulas and the closest i got gave me only the first result and it was combination of filter and vlookup but i accidently deleted that and can't really reproduce it...
added formula to your sheet. Please test it out:
=ARRAYFORMULA(QUERY(LAMBDA(ax,{PROPER(INDEX(ax,,1)),IFERROR(SPLIT(VLOOKUP(INDEX(ax,,2),A:A&"šŸ "&B:B,1,),"šŸ "))})(QUERY(SPLIT(FLATTEN(D3:D&"|"&E3:E&"šŸ "&TRANSPOSE(G3:G10)),"|",0,0),"Select * Where Col1!=''")),"Select * Where Col2!=''"))
-
Another option it stacks up different queries with REDUCE, also gives you a message if product is not found in that colour:
=REDUCE({A2:B2,"colour"},SEQUENCE(COUNTA(E3:E)),LAMBDA(a,v,{a; IFERROR (QUERY(A3:B100,"SELECT '"&INDEX(D3:D,v)&"',A,B where A = '"&INDEX(E3:E,v)&"' and B matches '"&JOIN("|",FILTER(G3:G,G3:G<>""))&"' label '"&INDEX(D3:D,v)&"' ''",),{INDEX(D3:D,v),INDEX(E3:E,v),"not found in any colour"})}))
try:
=INDEX(QUERY({VLOOKUP(A3:A10, {E3:E10, D3:D10}, 2, ), A3:B10},
"where Col3 matches '"&TEXTJOIN("|", 1, G3:G10)&"'", ))

How to import some Infinitely Repeating Offset-Cells from an ImportRanged WorkSheet? (Google Sheets)

I'm trying to import some specific cells from one worksheet to another, and I want to do so in a repeating, intermittent way.
For instance, if A51 is the first cell to be imported, I want to import A51 and all "reoccuring next fifth cells" in the same row (A56, then A61, then A66 and so on).
I figured I'd only need to use ArrayFormula, ImportRange and Offset, but I couldn't be more wrong. In my inexperienced mind, the formula would look something like this:
=ARRAYFORMULA(OFFSET(IMPORTRANGE("url";"Page1!A51:51");0;5))
... but it obviously doesn't work. I keep falling into the same problem no matter how much I tweek it, "the argument must be an interval". I've stumbled across similar problems here in StackOverflow, but none of them were quite the same issue; I tried their solutions and they also didn't work.
e.g. Exemple
So now I resort to you, great SO community. Could anyone explain to me why am I failing so miserably in a (most probably) simple task? I appreciate any help!
Thanks!
First see if you can just omit blank values and get the result you want. In the Input spreadsheet, choose Insert > New sheet and put this formula in cell E4 of the new sheet:
=query( transpose('PƔgina1'!B4:4); "where Col1 is not null"; 0 )
You can then do the same in the Output spreadsheet with these formulas:
=query( transpose(importrange("1el8PStX7NxRLbL-LC1afPTY3zAv2QqaQotRR18o0EjM"; "PƔgina1!B4:4")); "where Col1 is not null"; 0 )
=query( transpose(importrange("1el8PStX7NxRLbL-LC1afPTY3zAv2QqaQotRR18o0EjM"; "PƔgina1!B6:6")); "where Col1 is not null"; 0 )
If that is not what you needed, please show more realistic-looking sample data in the Input spreadsheet and the hand-entered results you would like to get from that data in the Output sheet. Do not show ColB;Row4 but the actual results you would like to get.

Q: Transpose -> Merge(?) on google sheets

Trying to transpose data such that rows transpose into a single column stacking on top of each other.
=ARRAYFORMULA({TRANSPOSE(A1:C1);TRANSPOSE(A2:C2);TRANSPOSE(A3:C3)})
This formula essentially does what I want but what if I have many more rows? Would I need to enter; TRANSPOSE(Col(x):Col(y)) for every single row?
Any help is appreciated.
Please try:
=TRANSPOSE(SPLIT(TEXTJOIN(",",1,A:C),","))
Notes:
textjoin will join text and skip blanks. Add spaces in column C to have an empty row.
limit of join function is 50000 characters
Max Makhrov's answer is good, but indeed subject to the 50k limit. To get around that, I have recently found another method which is explained in my
interlacing answer to another question
In your case this would look something like this (up to arbitrary 9 rows):
=query(
sort(
{arrayformula({row(A1:A9)*3, A1:A9});
arrayformula({row(B1:B9)*3+1, B1:B9});
arrayformula({row(C1:C9)*3+2, C1:C9})}
),
"select Col2")
Am I missing something, or why does nobody suggest Flatten?
FLATTEN(A1:C3)
And you can use Filter as usual to filter out blank cells, e.g.
=FILTER(FLATTEN(A1:C3);FLATTEN(A1:C3)<>"")

Filter order data to rows

I need to make sheet that will contain each order code, address, quantity and dates in one row for each order code.
I have sheet "Data" with orders (Address ID, Product code, quantity and Order ID) and i need to put it in other sheet "Export" in specific order. Is there a way to do it with functions or script?
I made test spreadsheet so everyone can see preview of what i need: test sheet
For example i have Address ID A001, i need to get each code and quantity from this address ID and put in row, in test spreadsheet i made example.
Sorry if I am asking too much, but i need some help or advice :)
Made picture so it would be easier to understand:
picture
The operation you need is called "unpivot" and has a couple of possible solutions, some of them purely functional and some utilizing Google Apps Script. Search for "unpivot" to explore them. Here goes one of possible functional solutions. It is simplified compared to your precise needs because I am not sure which of your headers ("dimensions") are unique. I'm assuming here that only the product code and address id are unique, because it looks like this in the data.
Make a new worksheet and put the formula below in A1:
=arrayformula(
split(
transpose(
split(
concatenate(
arrayformula(Data!$A$5:$A & "|" &Data!$C$3:$G$3 & "\"
)
);
"\")
);
"|")
)
Then put another formula in C1:
=arrayformula(
vlookup(A1:A; Data!$A$5:$G; match(B1:B; Data!$C$3:$G$3; 0)+2; 0)
)
This will give you the rudimentary idea of how to construct first the list of all possible combinations of dimension values (Code, Address ID in this case) and then fill in possible dependent values using VLOOKUP. Then you can use more VLOOKUPS to add more columns as needed.

Google Spreadsheet Function That Sums Numbers In A Column When the Row Contains An EXACT Text

I've been at this problem for a while now. I am trying to sum numbers under a specific column when the rows equal a certain text and then display that sum on a different sheet. So far I came up with this formula: =IF(EXACT(A2,Table!A2:A)=TRUE,SUM(Table!C2:C)); however the only problem is that is sums everything in column C (which makes sense).
I wish there was a way to do something like the following: SUM(Table!C2:C where EXACT(A2,TABLE!A2:A)=TRUE). I've also tried the SUMIF(), DSUM(), and QUERY() functions to no avail. I must be getting logically tripped up somewhere.
Figured it out: =SUM(FILTER(Table!E4:E, EXACT(Table!A4:A,A4)=TRUE)).
=sum ( FILTER (b1:b10, a1:a10 = "Text" ) )
// the above formula will help you to take the sum of the values in column B when another column A contain a specific text.
The formula is applicable only in Google Spreadsheets

Resources