In Google Sheets, how to transpose multiple column headers and data into a single column of multiple rows (I Column to 1 row each) - google-sheets

My question is very close to that other one:
In Google Sheets, how to transpose multiple column headers and data into a single column of multiple row labels and data
My Input (minimal example of 3 columns, but in reality 100's of columns):
GROUP 1
GROUP 2
GROUP 3
aa
b
cc
aaa
bb
cc
aaaaa
bbb
ccc
aa
bbb
ccc
a
bbb
ccc
bbb
bbbb
Needed Output:
GROUP 1
aa
aaa
aaaaa
aa
a
GROUP 2
b
bb
bbb
bbb
bbb
bbb
GROUP 3
cc
cc
ccc
ccc
ccc
The columns need to be with dynamic ending because their lengths are irregular.
So far I've only managed to use the usual transpose method by manually transposing each columns as so:
IN COLUMN F1:F:
=transpose(A1:A)
=transpose(B1:B)
=transpose(C1:C)
etc.
That is an error prone and very manual process for hundreds of columns.
What way would be a more efficent process to modify #player0 's formula in linked post to suit the above use?
Your help is appreciated very much.

In order to provide a proper response to the question, I'm writing this answer as a community wiki, since the issue was resolved from the comments section.
=TRANSPOSE(A:C)
References
https://support.google.com/docs/answer/3094262

Related

Spreadsheet, result of multiple connected formulas depending on value from list

A little bit frustrating as I knew how to do it years ago and right now I can't event ask Google accurate question to find the answer so I'm comming here :)
The sample spreadsheet will be almost self explanatory:
https://ethercalc.net/onpoo16pjeld
Extremely simplified version would be:
A | B
1 | input: |100
2 | formula1 |=B1 * 1.5
3 | formula2 |=B2 + 20
4 | 90 |=result of B3 when B1 = A4
5 | 150 |=result of B3 when B1 = A5
6 | 200 |=result of B3 when B1 = A6
I need result of last formula in the chain basing on different initial values.
I'll appreciate Google Sheet formulas, thank you.
My interpretation of the question is that you are asking for something like Excel's 'Data Tables' function, where (given some sort of mathematical model where the logic is chained over multiple cells from 1 or 2 input cell(s) each containing a single value into one output cell) the user can define the input and output cells and then create a table where Excel feeds multiple values into the input cell(s) and records the output value for each one according to the model. Google Sheets doesn't natively support this; the add-on below claims to replicate the Data Table functionality (https://workspace.google.com/marketplace/app/whatif/430660745752) but I have no experience with it. The 'best' option is still probably to condense all the logic into one arrayformula as per Tedinoz's answer - if there's a concern that this will make the model more difficult to understand because the individual steps are no longer spread out over multiple cells then it should be possible to use LAMBDAs to label all the steps to make the arrayformula easier to follow.
This formula assumes that the value in Cell B2 = Cell B1 x 120%
Enter this formula in cell F2:
=arrayformula(((E2:E7+(E2:E7*2/5))*1.15)+ (IF((E2:E7*2/5)>150, 50, 80)))
Output

Look up value and return 1 row below

I've been trying to figure out how to find a value in a table and return the string below that.
Most solutions I've tried with index don't work, and I don't think the solution is through vlookup.
So to give an example, I want the formula to look at today() and return the value 1 or 2 rows below corresponding to that date (which row is dependent on the AM/PM, but I'm pretty sure I can set that up with Ifs)
Let's say it's 26-08, 1PM then the formula should return 'Eee' as value in the following table:
25-08-2022 26-08-2022 27-08-2022
Aaa Bbb Ccc
Ddd Eee Fff
28-08-2022 29-08-2022 30-08-2022
Ggg Hhh Iii
Jjj Kkk Lll
Give a try on below formula-
=INDEX(A1:C6, MAX(ROW(A1:C6)*(A1:C6=E1))+IF(F1="AM",1,2),MAX(COLUMN(A1:C6)*(A1:C6=E1)))

copy-paste between Google sheets

I'm looking for a way to copy and paste data between 2 Google Sheets spreadsheets: in spreadsheet 1 I have a shared planner of 10 people, where each marks in his sheet personal commitments divided between morning and afternoon for each day. There are also two spaces M and P where everyone manually marks commitments with me.
In spreadsheet 2 I have the small jobs assigned to each of them with a summary line that tells me if they are free (they can do up to 3 jobs M and P).
I would like to copy the data in this row in the M and P columns in the sheet of each of them.
If you are looking to copy and paste data, you could use CTRL + C CTRL + V as suggested by #Jeremy Thille.
If you want to reference data from another sheet, you can do it this way : =NameOfYourSheet!A1, or ='Name Of Your Sheet'!A1 if the name contains spaces.
If the data is on a different spreadsheet, you have to use IMPORTRANGE function. Take a look at https://support.google.com/docs/answer/3093340.
Not sure about the javascript tag, google-sheets would have been more appropriate.
I was not able to explain it and so I send you an image of files.
I have to copy the row "Peter" in Sheet 2 and paste in sheet 1 following the date and sharing of M (morning) and P (afternoon). In suggested way it is too long, and so I thought to GS.
In image2 you find the result I would like to have
Meanwhile I find a formula that I put in Peter tab, cell marked M and P (1/10) and works very well
in B4 =transpose(query({Planning!A3:DT3};"Select "&ArrayFormula(join(", ";text(query(transpose({column(Planning!C3:BL3);mod(column(Planning!C3:BL3)-column(Planning!C3);2)});"Select Col1 where Col2=0");"Col0")))))
in C4 =transpose(query({Planning!A3:DT3};"Select "&ArrayFormula(join(", ";text(query(transpose({column(Planning!D3:BL3);mod(column(Planning!D3:BL3)-column(Planning!D3);2)});"Select Col1 where Col2=0");"Col0")))))
I have 25 people tabs with six month planning. At the end ok week I delete the related data.
How can I make automatic the work?
Meanwhile I find a formula that I put in Peter tab, cell marked M and P (1/10) and works very well in B4 =transpose(query({Planning!A3:DT3};"Select "&ArrayFormula(join(", ";text(query(transpose({column(Planning!C3:BL3);mod(column(Planning!C3:BL3)-column(Planning!C3);2)});"Select Col1 where Col2=0");"Col0")))))
in C4 =transpose(query({Planning!A3:DT3};"Select "&ArrayFormula(join(", ";text(query(transpose({column(Planning!D3:BL3);mod(column(Planning!D3:BL3)-column(Planning!D3);2)});"Select Col1 where Col2=0");"Col0")))))
I have 25 people tabs with six month planning. At the end ok week I delete the related data. How can I make automatic the work?

Count numbers in text field

I have a spreadsheet that contains cells similar to this:
AAA Up 3
AAA Down 2
BBB Up 1
BBB Down 3
CCC Up 5
CCC Down 2
So it's always some sort of text, followed by Up or Down, and then how often it went up or down. I'd like to count how many times went up or down. In this example the total of Up would be 9, and Down 7. How do I do that in Excel/Google Sheets? I couldn't find a combination of functions that would help me get this problem solved.
I forgot to mention that each row here is one cell. Or in other words, all of the text above is one column only.
Thank you.
It's straightforward in Google Sheets:
=ArrayFormula(query(split(A:A," "),"select Col2,sum(Col3) where Col3 is not null group by Col2"))
Here is another suggestion.
A single formula, shorter than the one by Erik and more robust than the one by Tom.
=QUERY(INDEX(SPLIT(REGEXEXTRACT(A:A,"\w+ \d+$")," ")),
"select Col1, sum(Col2) where Col2 is not null group by Col1")
Functions used:
QUERY
INDEX
SPLIT
REGEXEXTRACT
If we can assume only 1 or 2 digits in the number field then for Up use:
=SUMPRODUCT(--(RIGHT(A1:A6,2))*ISNUMBER(SEARCH(" Up ",A1:A6)))
and for Down use:
=SUMPRODUCT(--(RIGHT(A1:A6,2))*ISNUMBER(SEARCH(" Down ",A1:A6)))
There are many replies here. I'll suggest another and then tell you why it may be different:
=ArrayFormula(QUERY(SPLIT(REGEXEXTRACT(FILTER(A2:A,A2:A<>"")," ([UpDown]+ \d+)$")," ",0),"Select Col1, SUM(Col2) GROUP BY Col1 Label SUM(Col2) ''"))
It's not clear from your post whether "AAA," "BBB," etc. will be solid blocks of alpha-numeric information in your real application. I can imagine that the opening text might actually be strings with spaces (e.g., "Joe Schmoe from Idaho UP 3"). If so, some of the other formulas I see here will fail; but this formula will account for that.
Though a bit crude, but it'll work. Let us assume your data is in A2:A7 like this
AAAAAA Up 300
AAA Down 2
BBB Up 10
BBB Down 3
CCC Up 5
CCC Down 2
Enter this array formula in cell B2 (and copy downwards) [don't forget to use ctrl+shift+enter)
=VALUE(RIGHT(A2,LEN(A2)-MIN(SEARCH({0,1,2,3,4,5,6,7,8,9},A2&"0123456789"))+1))
Enter Up in C1 , Down in D1 and then enter this formula in C2 (and copy downwards and then rightwards so that cells C2:D7 are filled with this formula)
=--NOT(ISERROR(FIND(C$1,$A2)))
Now to sum Up values - use this formula
=SUMPRODUCT(C2:C7,B2:B7)
and for Down use this
=SUMPRODUCT(D2:D7,B2:B7)
You'll get desired sums
I see that a game of "whose is shorter" has begun. First (for those who don't know), a shorter formula doesn't necessary hold any advantages over a longer one as far as processing ability or speed. In fact, a formula that is a bit longer may hold benefits in terms of ease of understanding, getting rid of superfluous elements, etc.
That said, it seems to be, as I say, a sort of game for people who write formulas often to cut characters. So with only fun in mind, I toss this into the hat as well:
={"Up",SUM(FILTER(SPLIT(A2:A," "),FIND(" Up",A2:A)));"Down",SUM(FILTER(SPLIT(A2:A," "),FIND(" Down",A2:A)))}
It's shorter than the one by marikamitsos and gets rid of the "sum" header, which may or may not be wanted. It also allows for "Up" to be at the top without extra code (or by switching the clauses around, it gains no length and allows for "Down" to be at the top if desired).

How do I order a mixed text and integer field in a pivot table in Google Sheets?

Let's say that we have two columns on a sheet:
Name Room
-------------
Steve A1
Jill A1
Sam A1
Steve A2
...
Lisa A10
Sally A11
Jim A11
My actual dataset has up to a hundred of these rooms.
The issue I'm running into is with pivot tables. When I want to get a list of rooms and the count (counta is the one I'm using) it works, but the order is not what I wanted. It comes out as:
Room Count
--------------
A1 3
A10 1
A11 2
...
A2 1
I guess I can kind of see why it would be doing that. I'd much rather have it list it out in order. A1, A2, A3... A10, A11, A12, etc.
Is there an easy way to do this without some sort of data manipulation?
An "easy" way to do this without "data manipulation" is to copy the PT, Paste special, Paste values only and then drag the relevant rows (presumably at most only 8) to where you want them. The easiest way is probably with "data manipulation", for example:
=if(len(A1)=2,SUBSTITUTE(A1,"A","A0"),A1)
(Though in you case, whichever column would be the right one, it would not be ColumnA.)
I suggest you transform the string elements into number values using a lookup table.
I've created a sample spreadsheet here.
The input data in the 'input' sheet has the keys as you described.
The next sheet is the "lookup table" to translate each key into a value number. I suggest choosing large numbers to leave room for future intermediate numbers if needed
Pivot 1 is based on the original data as you described
Pivot 2 is based on the re-calculated room name using the lookup table.
The formula I used for the re-calculation is:
=VALUE(SUBSTITUTE(A2,MID(A2,1,1),VLOOKUP(MID(A2,1,1),'Lookup table'!$A$1:$B$2,2)))
I was a little lazy with the string lookup in the original name (MID), assuming your string is the first character and is 1 character long. This can be mended specifically with pattern matching.

Resources