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.
Related
I want the title in Cell A1 (Example Title) to be in a row next to each entry in Cell B1 so my desired result is:
In Excel OR Google Sheets. I only see "Split Text To Columns"
There are many ways to go about this. I'll suggest one of them.
Suppose that your raw data is in Sheet1!:A2:B. Add a "Sheet2" and make sure that A:B is empty. Then place the following formula in Sheet2!A1:
=ArrayFormula(QUERY(SPLIT(FLATTEN(SPLIT(REGEXREPLACE(CHAR(10)&Sheet1!B2:B,CHAR(10),"~"&Sheet1!A2:A&"|"),"~",1,1)),"|"),"Select * WHERE Col2 Is Not Null"))
To understand how this works, you need to work from the inside out.
First, an extra line break (CHAR(10)) is added to the start of each cell in B2:B. This is to create a uniform breaking point before every entry in the Column-B cells.
That now-uniform CHAR(10) is replaced by REGEXREPLACE with a concatenation of a tilde (~), the Sheet1!A2:A data for that row and a pipe symbol (|). Thus far, all of the virtually-held data for Sheet1!B2:B will still be within its original cell space.
SPLIT now splits that new data at the tilde to create individual horizontal cells that each now contain a separate copy of the Sheet1!A2:A label, a tilde, and one of the list items from Sheet1!B2:B.
This new virtual horizontal and vertical grid is then FLATTENed into one column.
Again, SPLIT is applied to separate the Sheet1!A2:A label from each of the now-individual Sheet1!B2:B entries, resulting in two columns.
'QUERY` is applied to keep only those results which are not null in the second column (ruling out any results for blank rows in the raw data or errors in column one formed by the previous functions, particularly those caused with the assumption that your number of individual data points in each cell of Sheet1!B2:B will vary).
I'm trying to grab a subset of covid data from a cell in google sheets that contains a lot of superfluous data.
Specifically, the LDH vaccine information tab here has a tab containing "Vaccination by Gender by Parish" which has two things repeated 64 times: A line containing information on total series initiated and completed per parish, and a chart showing the percentage breakdowns by gender for that parish.
I'm importing this tab by copy/pasting into a google form (splitting it in 2 halfway through to get around the character limit). It returns a massive cell (or, two cells rather) containing 32(x2) instances of both the lines containing parish vaccine data and several lines containing the chart data.
Is there a way I'm not seeing to create an array formula that will isolate the two segments? I don't need the gender breakdown information, just the top-line numbers per parish. If I can get the top-line numbers into a separate cell together, I can use a split function on them, but can't separate everything correctly using the split function from a single cell.
This is the shortest of three lists/charts that display the information as a raw string (on the front-facing side, which I need to use because other people will be inputting this data into the sheet).
Edit: Here's a viewable version of the sheet.
To get to the correct tab, click "Vaccination Information" at the top of the ArcGIS dashboard. Then, click the left arrow at the bottom of the dashboard until it displays "Vaccination by Gender by Parish."
Since it is not possible to use automatic import using formulas and you have to use copy-paste, you can get the result you want faster this way.
Copy from the site and paste the data on the sheet.
Filter and remove unnecessary rows.
Split the text into columns using the "-" separator.
Search and replace, remove text and spaces from the data columns.
i have a sheet along with this question,the formula used in column E2 is : if(and(d2>=0,d2<=2),5. So when the column is blank it gives the value 5 My query is can we left the "E" column blank when there is no value in "D". ??? 5 must displayed only if there score between 0 & 2.
https://docs.google.com/spreadsheets/d/1XpdXcWDReB8TGvZ6ocALAilVPLDKzZXvd90YhNos0Io/edit?usp=sharing
Iker. I've added a sheet with two approaches.
If you want to drag the formula, just set an initial IF that rules out blanks like this:
=if(D2="","",if(and(D2>=0,D2<=2),5,if(and(D2>=3,D2<=4),0)))
I placed this into my sheet, E2, and dragged down as you were doing.
However, this is a great example of where array formulas are handy. An array formula can "run" your whole column from just one cell. I placed the following array formula into cell I1 of my sheet:
=ArrayFormula({"POINT";IF(H2:H="","",IF((H2:H>=0)*(H2:H<=2),5,IF((H2:H>=3)*(H2:H<=4),0,"")))})
First, keep in mind that array formulas must have unused space below them in order to fill in results. If you type anything manually below an array formula, inside the range it is trying to work on, you'll get an error. If you do want to put other data below an array formula, just limit the range in the array formula (e.g., change every H2:H to H2:H6 or whatever the end of that data range might be).
ArrayFormula() tells Google Sheets to apply this formula to the entire range in the formula. Since the range in the formula is H2:H, every cell in I2:I will be "reserved" by this array formula.
The curly brackets {} allow us to build another custom array inside the first array.
Since I want a header in I1, I put that header name first in the curly brackets. The semicolon tells the array to put the next part underneath.
The next part may look strange, but it's basically the same as your original formula, except that AND(), OR(), etc., don't work inside arrays. So the logical operators inside arrays are different. In this case, an asterisk * means AND.
The same conditions from your original formula are used here. And if it meets none of those criteria (for instance, if someone entered -1 or 7 or M somewhere in Column H, the last part of the last IF would just assign a blank.
You can use an added IF to your formula
=IF(D2="","", if(and(D2>=0,D2<=2),5,if(and(D2>=3,D2<=4),0)))
Is there a way to delete empty cells in a given range and shift the column up to the desired display as shown below? Closest I came was
=ARRAYFORMULA({A1:C1; TRANSPOSE(SPLIT(TRANSPOSE(QUERY(A2:C,,999^99)), " "))})
which removes empty cells, but splits the first names and surnames into separate cells, which I have not figured out how to avoid. Pfa a made-up sample of current and desired displays:
Current Display
Desired Display
I'm new at this, but I came up with a bit of a brute force method, which may help you.
={
{(A1:C1)};
{FILTER(A2:A100,A2:A100<>"");indirect("N1:N" & 100-counta(A2:A100))},
{FILTER(B2:B100,B2:B100<>"");indirect("N1:N" & 100-counta(B2:B100))},
{FILTER(C2:C100,C2:C100<>"");indirect("N1:N" & 100-counta(C2:C100))}}
Assuming your data block is in columns A1:C100, this formula filters blank cells from each individual column, and then pads each column with blank cells at the bottom, to make the three arrays equal in length/dimension.
Note that in "100-counta(...", the 100 is the expected maximum length of your data column.
This could be calculated, and must be the same for all three columns.
Note also that the first array is horizontal (ends with a semi-colon), followed by the three columns, stacked beside each other (ends with a comma).
Here is a working example.
https://docs.google.com/spreadsheets/d/1MGaqqGrkmIliuAzEqxPtdEVZXWPN2K5W7jFFM-ZnwgE/edit?usp=sharing
If I missed something you were trying to achieve, let me know.
Also, I'm sure that there is a more elegant way to do this, or one not requiring the use of a block of "reserved" blank cells, but I couldn't think of that at the moment.
Edit: The formula as follows also works. But you need to remember to set the "100" value to be equal to the number of rows in your data block, since we pad the columns with the necessary number of blanks rows, after removing the blank cells in each column.
={
{(A1:C1)};
{FILTER(A2:A,A2:A<>"");indirect("N1:N" & 100-counta(A2:A))},
{FILTER(B2:B,B2:B<>"");indirect("N1:N" & 100-counta(B2:B))},
{FILTER(C2:C,C2:C<>"");indirect("N1:N" & 100-counta(C2:C))}}
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