Google Sheets Fill Down with Formula - google-sheets

I have a very hard problem to solve, which must be completed with a formula (not a script).
Basically, the Raw input column needs to be dynamically filled down until it hits the next piece of text.
Here's an example file with includes the expected output.
https://docs.google.com/spreadsheets/d/1ibqCvY39NlhCRWsbBdxKITUUpVpp9wXdEz44T-pHDY0/
Is it even possible to achieve?
Thanks

This will work based on your ask, assuming that A2 is never blank, place this in the first row of data (not header):
=ArrayFormula(IF(A2:A<>"", A2:A, B1:B))
It checks to see if there is a value in column A, if there is, it fills that column, if not, it copies the cell above.

Delete everything in Column B (including the header) and place the following formula in B1:
=ArrayFormula({"Header";VLOOKUP(FILTER(ROW(A2:A),ROW(A2:A)<=MAX(FILTER(ROW(A2:A),A2:A<>""))),FILTER({ROW(A2:A),A2:A},A2:A<>""),2,TRUE)})
Here is a basic explanation of how this formula works:
A virtual array is created between the curly brackets { }; this virtual array contains a header and all results. You can change the header name to whatever you like.
VLOOKUP looks up every row number that is less than or equal to the highest row number that contains text in A2:A. Each of these qualifying rows is looked up in a second array that contains only the row numbers and Column-A data from non-blank rows, returning the data itself. Since rows are in perfect ascending order and the last parameter of VLOOKUP is set to TRUE, all blank rows in the first array will "fall backward" to find the most recent row that did have something in Column A.

Related

Compiling a list using INDEX but need to skip certain rows

I'm compiling a list based on the first answers recieved between row N and AF.
I'm using these two formulas:
=INDEX(N2:O2,MATCH(FALSE,ISBLANK(N2:O2),0))
and
=INDEX(R2:AF2,MATCH(FALSE,ISBLANK(R2:AF2),0))
Is there a way to combine them whilst not searching in rows P & Q?
These are generated from a Form response so can't just be switched around.
try:
=INDEX({N2:O2, R2:AF2}, MATCH(FALSE, ISBLANK({N2:O2, R2:AF2}), 0))
If Sheet1 is an intake sheet of form results, you should not add any data, formulas or even formatting to that sheet. It virtually always causes issues. A form intake sheet should be left exactly as it is. A new sheet can then be used to bring over the results of the form intake sheet as you want to see them.
However, since you didn't specify any of that, I will supply a formula written to work in the same sheet as your posted example and in-sheet examples.
Clear an entire column and place the following in the top cell of that column:
=ArrayFormula({"Attendee Name"; IF(E2:E="",,IFERROR(REGEXEXTRACT(TRIM(TRANSPOSE(QUERY(TRANSPOSE(FILTER(IF(N2:AK="",,N2:AK&"~"),N1:AK1=N1)),,COLUMNS(N1:AK1)))),"\s*([^~]+)"),"(none listed)"))})
This one formula will produce a header (the text of which you can change within the formula itself as you lie) and all valid results for all rows.
The inner IF will append a tilde (~) to any non-null entries in the range N2:AK.
FILTER will keep only those columns in this range where the header is the same as the header in N1 (i.e., "Attendee Name").
TRANSPOSE(QUERY(TRANSPOSE( ),,COLUMNS( ))) is colloquially called a "Query smash." It will form one cell from all horizontal results per row.
TRIM will cut any preliminary spaces and form a true string.
REGEXEXTRACT will pull the from the first non-space character up to but not including the first tilde (from those appended in the first step)—in other words, the first full valid entry from any column.
IFERROR will return a message if there is an error, with the likely error being that there were no valid entries for "Attendee name" in any column.
The outer IF will leave the cell blank if the no training event exists in E2:E.
{ } forms a virtual array that places the header over all other results.
ArrayFormula( ) signifies that multiple results will be processed at once.
Because this is an array formula that is being "asked" to process every row, you cannot manually type into any cell of this results column. If you do, you will "break the array"; everything except what you just typed will disappear, leaving only an error in the formula cell. If you need to add or change a name, you need to do that in the raw results range (e.g., manually type a name or a new name in Col N), which will then turn up in the formula output range.

Lookup and fetch multiple delimited partner names

I have list of partner name codes, delimited by space. Like the one shown in below,
I have another table(E:F), from where I have to map them to show the partner names like the column C, perhaps i am not able to understand how to make it happen,
I have tried using this formula which brings only one partner name but when there are multiple it does not shows up, do i need to add another function like TEXTJOIN or what I am doing wrong here.
=IFERROR(VLOOKUP(IFERROR(REGEXEXTRACT(A2,JOIN("|",FILTER($E$2:$E,$E$2:$E<>""))),""),$E$2:$F,2,0),"")
Link To GS
See my sheet ("Erik Help"). The following formula is in cell B1:
=ArrayFormula({"PARTNER NAMES";IF(A2:A="",,REGEXREPLACE(TRIM(TRANSPOSE(QUERY(TRANSPOSE(IFERROR(VLOOKUP(SPLIT(A2:A," ",0,1),D:E,2,FALSE)&",")),,COLUMNS(SPLIT(A2:A," ",0,1))))),",$",""))})
This one formula produces the header (which you can change within the formula itself as you like) and all results for all rows.
IF(A2:A="",,...) means if a cell in Col A is blank, then the result in the same row of Col B will also be blank (i.e., null).
SPLIT (the first time in the formula) will split the Col-A values at the spaces.
VLOOKUP will try to find each split value in the D:E list. If found, the full name will replace the initials. If not found, IFERROR will return null.
You will see &",". That is appending a comma to any full names that are returned.
TRANSPOSE(QUERY(TRANSPOSE...),,COLUMNS())) is what many call "QUERY Smash." It basically, flips the remaining results of the VLOOKUP into columns instead of rows, turns everything into headers (to get them in one cell per column) and then flips them back to row orientation.
TRIM gets rid of spaces where no names were found in the full list.
REGEXREPLACE(... ,",$","") replaces any final comma that has no name after it with null.

Insert duplicate rows (based on one cell-value) in google sheets

So I have this formula that copies rows (with data in col A) into a new range. Column A contains number indicating how many duplicates the row should yield in the result. Also the output rows gets sorted based on the value in column A.
=sort(arrayformula(vlookup(
transpose(split(query(rept(row(D2:D)&" ",A2:A),,9^9)," ")),
arrayformula({row(D2:D),{A2:A,D2:F}}),
{2,3,4,5},
0)),
1,
TRUE)
This is not exectly what I need thou. Instead of having a single value in the cells in column A that indicates how many times the row should be duplicated I need to have a text string like “2,3,5” in every cell in that column, where the individual numbers in the string indicates the position of the row in output (rather than the number of times the row should be copied).
For example, in the output I want the row with the string “2,3,5” to be copied three times. The output should have one of the rows be 2:nd from top, the other 3:rd from top, and the last one the 5:th from top.
If I could have the A2:A part of this range {A2:A,J2:N} instead contain the matching values for split(A2:A) I think it would do what I want.
This is a copy of my google sheet. Hopefully it's possible to understand what it is I'm trying to achieve.
https://docs.google.com/spreadsheets/d/1sp5DRBwFP0-aG-FvjUPKBmyylz0WoPB63ASOOdUGdnI/edit?usp=sharing

Sum above cells ignoring blanks

I have a spreadsheet where I have data from a bank account. Each bank transaction has a date and an indication if that transaction is already done or if it's just expected. When it's already done, it must be added to the total balance up to date. If not, then the total balance up to date must be blank. I need to autofilter the data, so I can filter and order it depending on date or other conditions, that's why I've been using this formula:
=IF(D3="Y";B3+INDIRECT(ADDRESS(ROW()-1;COLUMN()));"")
Problem here is that when the cell above is blank, total sum resets and it starts from the value of that transaction. I need a formula that ignores the upper blank cells, and sums all cells above that are not blank plus the amount of that transaction.
Besides, once I change the "N" in "Done" Column to a "Y" I need the formula to update and show the correct balance.
I share an example sheet for better understanding https://docs.google.com/spreadsheets/d/1_gk0YaziUhOZfRbrlfHizMrVu6OT7njIaTUyQaE6Lbs/edit?usp=sharing
Ok I THINK I understand what your going for - please let me know if I am confused, but I added an example on your sheet.... basically what I ended up doing was including one of your conditionals, but then also adding another function to exclude the blank rows by way of filter , index and counta It looks more complicated than it is because I nested it all back into one formula:
=IF(I3="Y";sum(G3;index(filter(indirect("F2:"&address(row()-1;column();4));ISNUMBER(indirect("F2:"&address(row()-1;column();4))));counta(filter(indirect("F2:"&address(row()-1;column();4));ISNUMBER(indirect("F2:"&address(row()-1;column();4)))))););)
To work it from the inside out - the way I am excluding the blank rows is by using FILTER to get all the rows from the first row with a value ( Like A2 in your example) and using INDIRECT and ADDRESS to end the array I want to include exactly one cell above the current cell.
Then I use the condition that the range I built has a number value in it, there fore excluding the blanks.
In order to get the last value available, I use COUNTA to find out the total rows in the filter, then wrap the formula with INDEX to use the counta value as the row to return (which automatically is the last row available above the current cell)
Try this in A3 and copy down:
=IF(D3="Y";B3+INDIRECT(ADDRESS(ROW()-1;COLUMN()));A2+0)
If you want to display the "N" rows as blank, add a column (B) fill in the header and the starting number (5000) then put this in B3:
=if(E3="N";"";A3)
Copy it down then hide column A.

How to use INDEX() inside ARRAYFORMULA()?

I am trying to use the INDEX() formula inside an ARRAYFORMULA(). As a simple (non-sense) example, with 4 elements in column A, I expected that the following array formula entered in B1 would display all four elements from A in column B:
=ARRAYFORMULA(INDEX($A$1:$A$4,ROW($A$1:$A$4)))
However, this only fills field B1 with a the value found in A1.
When I enter
=ARRAYFORMULA(ROW($A$1:$A$4))
in B1, then I do see all numbers 1 to 4 appear in column B. Why does my first array formula not expand similar like the second one does?
The INDEX function is one that does not support "iteration" over an array if an array is used as one of its arguments. There is no documentation of this that I know of; it simply is what it is. So the second argument will always default to the first element of the array, which is ROW(A1).
One clumsy workaround to achieve what you require relies on a second adjacent column existing next to the source data* (although it is unimportant what values are actually in that second column):
=ArrayFormula(HLOOKUP(IF(ROW($A$1:$A$4);$A$1);$A$1:$B$4;ROW($A$1:$A$4);0))
or indeed something like:
=ArrayFormula(HLOOKUP(IF({3;2;4;1};$A$1);$A$1:$B$4;{3;2;4;1};0))
edit 2015-06-09
* This is no longer a requirement in the newest version of Sheets; the second argument in the HLOOKUP can just be $A$1:$A$4.
Here is a tip for using vlookup with an array, so that even if the columns are moved later on the formula will still work correctly....
In general, configure the vlookup so that it's reading only 2 columns and returning the second. This can be done by inputting only the 2 columns required, rather than a range and column index.
Example:
Replace the following formula which would fail if columns are moved
=arrayformula( vlookup(C:C, booking!$A:$E ,5 ,false) )
with this formula which will continue to work even if columns are moved
=arrayformula( vlookup(C:C, {booking!$A:$A,booking!$E:$E} ,2 ,false) )
Note, you can also simulate the index function using vlookup.
Example:
Column R:R contains the row index numbers for looking up data in column booking!$A:$A
=arrayformula(vlookup(R:R ,arrayformula({row(booking!$A:$A), booking!$A:$A}),2 , false))
It's a nested array, so it can be helpful to test in stages, eg just the inner part for one example, eg return entry in row 10:
=vlookup(10 ,arrayformula({row(booking!$A:$A), booking!$A:$A}),2 , false)

Resources