I want to auto increment column A if column B is not empty.
For example if I type anything to B14, I want A14 to auto increment.
How can I do this?
if B column is not interrupted by an empty cell you are good with just:
=SEQUENCE(COUNTA(B2:B))
If column B is interrupted (or even not) by empty cells you could use
=INDEX(IFNA(VLOOKUP(ROW(A2:A),
{FILTER(ROW(A2:A),(B2:B<>"")),SEQUENCE(COUNTIF(B2:B,"<>"),1)},2,0)))
Here are some methods that may suit your needs...
This will auto-sequence while jumping blank rows, so will be the number of filled cells/rows:
=ARRAYFORMULA(IFERROR(MATCH($B$2:$B&ROW($B$2:$B),FILTER($B$2:$B&ROW($B$2:$B),$B$2:$B<>""),0)&"."))
This will auto-sequence while skipping blank rows, so the number will be the row of data (not the row number):
=ARRAYFORMULA(IF($B$2:$B<>"",ROW($B$2:$B)-ROW()+1 & ".",""))
or:
=ARRAYFORMULA(IF($B$2:$B<>"",SEQUENCE(ROWS($B$2:$B))&".",""))
And this will autofill every row up to the last row with a value:
=ARRAYFORMULA((QUOTIENT(SEQUENCE(SUMPRODUCT(MAX(($B2:$B<>"")*(ROW($B2:$B))))-1)-1,1)*1)+1)
Related
If I have column A receive 1000 rows of input and column B has some function that takes column A cells as input for some custom function. How do I control how many cells in column B can run at a time? For example
Column A receives input into rows 1-1000. Column B has rows 1-5 trigger. In order words, how to setup concurrency control for columns?
Edit: Referring to the picture - I will paste in 1000 cells of data into column A. I need column B to only process X rows/cells at a time.
based on your picture... if you want to process only 20 rows out of 1000 you could maybe try:
=ARRAYFORMULA(FUNCTION(A1:A20))
ofc if your Function supports the ArrayFormula variation
I have a bunch of data being pushed in a google sheet row by row. Each row has a reference number (COL A) and a date (COL D). For every reference number, I want to find the latest updated row. It's necessary that this is done by arrayformula.
So far I have a combination of arrayformula and filter. However it doesn't work as expected as one of the filter arguments is A2:A=A2:A. Obviously this is always true. What I want it to do is compare A2:A=A2 for row 2, then compare A2:A=A3 for row 3 etc. Without dragging down. Since the data is growing automatically
=arrayformula(if(len(A2:A),max(filter({D2:D},A2:A=A2:A)),))
https://docs.google.com/spreadsheets/d/16pbGiisFcsrHfrFKowzzkpw03Lw79yACjut96xxyWW4/edit?usp=sharing
try in E1:
={"Last Update";
ARRAYFORMULA(IFNA(VLOOKUP(A2:A; SORT({A2:A\ D2:D}; 2; 0); 2; 0)))}
You can paste this either of this formulas in F2 and then drag it down.
=QUERY($A$2:$E,"SELECT D WHERE A = '"&A2&"' ORDER BY D desc LIMIT 1")
=ARRAYFORMULA(MAX(FILTER({$D$2:$D},$A$2:$A=A2)))
*Edit:
Try this formula in F2 and there is no need to drag it down:
=ARRAYFORMULA(IFERROR(VLOOKUP(A2:A,QUERY(QUERY($A$2:$E,"SELECT A, max(D) WHERE A <> '' GROUP BY A"),"SELECT * OFFSET 1",0),2,FALSE),""))
You'll probably have give column F a date format, but it's a one time thing. Good luck :)
I have 2 columns in a sheet that are referencing another dynamic sheet which has new rows added at the top all the time.
I want column A to be a copy of column A in Sheet1, so this works to put in cell A1:
={Sheet1!A:A}
However, I want column B to a formula applied to every row in column B of Sheet1. Problem is, when I put in a a formula, e.g.
=formula(B1)
then it changes to
=formula(B30)
when 29 new rows added
I want it to stay as B1, but it won't. If I use an absolute reference $B$1 then I can't copy the formula down the column.
Any wizards out there to help me out?
If you want to get the matching row from a column of another worksheet, then use INDEX and ROW, like so:
=FORMULA(INDEX(Sheet1!$B:$B, ROW(), 1))
This will always return the value in Column B of Sheet1, on the same Row as the formula is in on Sheet2 - even if you insert rows at the top of Sheet1
You can do "partially absolute reference" (I don't know the correct way of saying this).
You can lock only the column so would be =$A1 which means that it will never change the column but when you drag down the formula, it will change to =$A2, =$A3...
Or you can lock only the row typing =A$1 This way it will be locked on the row only.
You can do this also by pressing F4 several times: 1 time will lock both, the 2nd time will lock the row only, the 3rd time the column only and the 4th time will delete the locking.
the proper way would be to use INDIRECT like:
=INDIRECT("Sheet1!B1:B")
I'm having trouble writing a VLOOKUP to sort some data.
I have one table that has data that looks like this:
MarkAsOfDate MaturityDate ZeroRate
05-May-15 05-May-15 0.006999933
05-May-15 06-May-15 0.006999933
05-May-15 05-Jun-15 0.008996562
05-May-15 06-Jul-15 0.008993128
... ....
I want to make a table with every instance where the interval between the dates in the first and second columns is exactly one month (such as 05 - May - 15 and 05 - Jun - 15), and with blanks where no such value exists.
So I made a second table which looks like:
MarkAsofDate MaturityDate Zero Rate 1M
5-May-15 5-Jun-15
6-May-15 6-Jun-15
7-May-15 7-Jun-15
8-May-15 8-Jun-15
9-May-15 9-Jun-15
.... ....
I want to populate this table using data from the first table. I've tried to write a VLOOKUP for it but I'm not sure how to do it with two columns instead of one.
Thanks in advance.
Vlookup has some limitations, as you're starting to see. Another suggestion is Index/Match. Use this in your second table.
Note: I assume your top table is in Sheet1. Put this in your C2, in the second table (under the "Zero Rate 1M" header):
=Index(Sheet1!$C:$C,match(A2&B2,Sheet1!$A:$A&Sheet1!$B:$B,0)) and enter by pressing CTRL+SHIFT+ENTER.
There are a lot of ways to do it - if your data is sorted first by MarkAsofDate and then by Maturity date, the simplest method will be to add a helper column on your raw data tab - let's say column E. In column E, starting at E2 and copied down, type [Assuming MarkAsofDate is column A & MaturityDate is column E]:
=IF(MONTH(B1)-MONTH(A1)=1,A1,"")
This column will show the MarkAsOfDate for every item which has a MaturityDate 1 month after the MarkAsOfDate; for all other rows it will show "".
In your special data results tab, use the MATCH function to find the row in column E which matches your current row's MarkAsOfDate. We will also use the INDEX function to return the value from that row in column C. Assuming your first sheet with raw data is sheet1 and your special data results is on sheet2, type this into E2 on sheet2 and drag down:
=INDEX(Sheet1!C:C,MATCH(A2,Sheet1!A:A,0))
Another alternative (apart from BruceWayne's recommended Array Formula) would be to use the OFFSET function. OFFSET creates a new range based on a starting point, moving a number of cells to the right/left/up/down, for a given height and width. In this case, we will first use MATCH to find the first time that the MarkAsOfDate on Sheet1 matches Sheet2. We will use that info and the OFFSET function to create a new range which starts there, and ends at the bottom of your data, like so:
=OFFSET(Sheet1!A1,MATCH(A2,Sheet1!A:A,0),1,COUNT(Sheet1!C:C),2)
Then we just need to use VLOOKUP on the range we created above, like so:
=VLOOKUP(B2,OFFSET(Sheet1!A1,MATCH(A2,Sheet1!A:A,0),1,COUNT(Sheet1!C:C),2),0)
This second alternative avoids needing a helper column, but is more complex and could be prone to errors if your rows/columns change (because we had to hardcode a couple of things in the OFFSET function). Also, OFFSET is volatile, meaning it recalculates whenever any cell calculates, so it can slow down your workbook if you have a lot of rows of it. Based on that, I recommend you either use the helper column method above, or if you are comfortable with Array Formulas, using BruceWayne's answer.
I need to find in a column of an excel spreadsheet the last non-error, non-blank value. The column can have several instaces of #N/A which are alternating with actual values. There are several solutions for finding the last non-empty cell, but the solutions do not consider errors, in particular if the last non-empty cell has got an error.
The solution would be 3 in this case.
Try this formula
=LOOKUP(2,1/(A1:A100<>""),A1:A100)
extend range as required. In Excel 2007 and later you can use the whole column
Eliminate #N/A error cells by using IFERROR(. . .
then
{=MAX(COLUMN(A4:A150)*(A4:A150<>0))} if A1 -style
or
{=MAX(COLUMN(RC4:RC150)*(RC4:RC150<>0))} if RC -style
{} ... array formula . .. ctrl+shift+enter
For Row - replace COLUMN with ROW