How to combine multiple rows into single column, or multiple columns - google-sheets

How can I take multiple rows of different data for one user, and move them into columns so that each user has only one row.
In my example, I have three tables. The table in red is the current data I have. The tables in green are what I want to convert the data to.
I tried moving each value into its own column with a formula placing a formula in a different column and moving the data over like this: In C2, =IF B2=21, B2' then copying the data into one row and deleting the others. This is long and complicated process and I am wondering if there is a better way.
https://docs.google.com/spreadsheets/d/1utqqw1Am0C_x80t1BiswHmIdWzEhNDHq4vtdBOnkGMI/edit?usp=sharing

You may try:
1st table
=byrow(unique(tocol(A2:A,1)),lambda(z,{z,join(", ",filter(B:B,A:A=z))}))
2nd table
=byrow(unique(tocol(A2:A,1)),lambda(z,{z,torow(filter(B:B,A:A=z))}))

Related

How to group columns by header in Google Sheets?

I have multiple tables populated in the same sheet, but need them in a single table. How do I dynamically create a single table? The raw data will change, so it needs to accept additional rows as they populate.
Here is a demo document with the raw data and desired effect.
https://docs.google.com/spreadsheets/d/1V8ytyN-qSUW0Wrba7FxmQ242YXSNQ18y6nneEz6bS5g/edit?usp=sharing
Your raw data should remain alone in its sheet. So first, remove everything you currently have in Sheet1!A12:D, since it will interfere with your ability to write formulas that allow the raw data in A:D to expand downward.
Once you've removed that, add a new sheet. In that sheet, use this formula:
=QUERY({Sheet1!A3:D3;Sheet1!A4:D;Sheet1!F4:I},"Select * Where Col1 Is Not Null")
The curly brackets allow the formation of a virtual array. Within those curly brackets, a semicolon means "place what comes next below" while a comma would mean "place what comes next beside." Understand that such virtual arrays must keep parallel structure at all times; for instance, you can't place a range that's four columns wide over one that's only three columns wide.
As written, those stacked ranges go all the way to the bottom of the sheet, since there is no row number on the second part of the range (e.g., A4:D means "the range that starts with A4 in the upper left and runs to the bottom of Column D, wherever that is"). By doing this, you are always able to include more data without adjusting the formula.
All that is left to do is weed out blank rows. The outer QUERY as written allows us to trim that virtual array to to only those rows where the first column is not empty.

Join two pairs of columns and eliminate duplicates into two columns

I need to join two pairs of column into two columns (not just one) and eliminate duplicates.
Take a look a this capture to see what I mean. I need to join yellow and blue cells to get the result in the green cells.
I tried with UNIQUE but it only accepts one argument, then I don't see how to add the second pair of columns.
The closest I get is this =CONCATENATE(UNIQUE(A3:B7);UNIQUE(D3:E5)) but I get all values in just one cell. Not what I need.
You can also take a look a this spreadsheet: https://docs.google.com/spreadsheets/d/1-x5KINErYKgwxgv5ZCpxbGdxRdp6NBDWMK2Cxhl5Xy8/edit?usp=sharing
You can use the following formula:
=UNIQUE({A3:B7;D3:E6})
Using curly quotes {} we create an array. Using ; we place these values one under the other and we then use unique.

How do I change the row that numbers are compared based on the data in another cell?

I am usually good with conditional formatting in excel/google sheets, but here is my current challenge. I am needing to format specific cells based on the data in a table at the top of the sheet where the row used for comparison changes based on the value in one cell. Here is the link to the sheet I am currently working on.
https://docs.google.com/spreadsheets/d/1t7pgvGjxs1Eb3cCcRnLDA6E9ov5riEDAjn-fX3A0s8I/edit?usp=sharing
-The table at the top of the is the reference table and does not change.
-the number in column E is the data that determines which row of the table to compare the data in columns G through AN
The Situation:
Let's look at Name 3.
The numbers in G18:AN18 are compared to the G12:AN12 because of the matching number in E18 and E12
If the number in G18 equals G12 - no formatting change
If the number in G18 is one less than G12 - fill color Yellow
If the number in G18 is more than one less than G12 - fill color Red
This is true for each cell in row 18 columns G:AN
- That's the easy part -
Now, when the number in E18 changes (from "9" to "10" for example), I need it to stop looking at row 12 and now look at row 13 because E18 now matches E13
I know that I can do it using nested IF/AND statements but I would have to do it for each and every cell individually. How can I do this more easily through google sheets?
You need to use INDEX/MATCH, so for the yellow formatting starting in G16:-
=G16=INDEX($G$4:$R$14,MATCH($E16,$E$4:$E$14,0),COLUMN(A:A))-1
The idea is that as you copy it across the column changes to B:B etc. so you get the next column of the top region and as you copy it down you get whichever row matches E16, E17 etc.
I'm sure you can modify it for the red formatting and also to take account of any blank cells.
Also, in this particular case that the numbers in E4:E14 are just the numbers 1-11, you could use E16:E25 to index directly into G4:R14 and make the formula a lot simpler like this:-
=G16=INDEX($G$4:$R$14,$E16,COLUMN(A:A))-1

Editing labels of series in Google Spreadsheets

I have data listed in columns as below and by highlighting it all including the names and the units and then clicking Insert -> Diagram..., I can easily make the following graph:
The labels are correct LabelA, Labelb, and LabelC in this case.
But if the label names are not in the same column as the data, then I cannot make this graph. In the data structure below where names and data are in different columns, I again highlight all data cells as well as their units and names (by holding down the ctrl button and clicking all the cells with the cursor):
It is clear that the software does not know that it should assign the names as labels. Is there a method to make the graph show the correct labeling as in the first scenario but with the second scenario's data structure?
you could combine the data in another place with formula:
={{A1,C1,E1};{B4:B6,D4:D6,F4:F6}}
and then plot the diagram as usual.

Sum imported range row-wise

I have a table with data in three columns, lets say from E26 to G47. What I want is to display the row-wise sum of this data in another spreadsheet, so the cell E26 of the other spreadsheet contains the sum of E26 to G26 from the first sheet. I tried to implement it in code, but I was unsuccessful:
=SUM(ImportRange("key"; "sheet!E26:G47"))
This sums the whole data of rows and columns in one cell.
=SUM(ImportRange("key"; "sheet!E26:G26"))
This does nothing.
How can I achieve this? Thanks!
One way:
=ArrayFormula(MMULT(ImportRange("key";"sheet!E26:G47");{1;1;1}))

Resources