Specify Column Range Except Second-to-last Row - google-sheets

I am currently using SUM on an entire column with the following formula:
=SUM(A2:A)
Unfortunately this total is displayed on the last row of this column, so it creates a circular reference, #REF, there that I need to get rid of. How can I make it so that it selects the column starting from the second row until the second-to-last?
I could change the formula manually every time I enter a new row, but that's not ideal at all.
Pseudocode
=SUM(A2:A[last row - 1])

See if this works
=sum(indirect("A2:A"&row()-1))

Related

Google Sheets Dragging part of a formula while keeping the rest intact

I have this formula in Google Sheets: =ROUND((J2*2)*('Sheetname'!C39/100))
I want to keep the (J2*2) consistent as I drag down;
at the same time I want to have ('Sheetname'!C39/100)) adjust to the next row as in ('Sheetname'!C40/100)) etc...
Use the $ sign to make it constant. if you want to make column constant place $ before column name if you want to make row constant put $ before the row value
To Use J2 cell value in all the computation
=ROUND(($J$2*2)*('Sheetname'!C39/100))
To Use J column value in all the computation, but change row based on drag
=ROUND(($J2*2)*('Sheetname'!C39/100))
To Use 2nd row value in all the computation, but change column based on drag
=ROUND((J$2*2)*('Sheetname'!C39/100))

How to use ARRAYFORMULA with OFFSET to previous row without getting circular reference error

Example sheet: https://docs.google.com/spreadsheets/d/14ma-y3esh1S_EkzHpFBvLb0GzDZZiDsSVXFktH3Rr_E/edit?usp=sharing
In column B of ItemData sheet, I have achieved the result I want by copying the formula into every cell in the column, but I want to solve this using ArrayFormula instead.
In column C I have achieved the same result using ArrayFormula. However, for addition, column C is referring to cells in column B, while column B is referring to cells in column B. I.e. every cell in column B is adding 1 to the cell on the row above.
If I select the C3 formula text and paste it into the cell edit field for cell B3 (to not screw up cell references during copy - I know I could make them static references, but this is not my problem), the cell gets an error value of
#REF!
Error
Circular dependency detected. To resolve with iterative calculation, see File > Spreadsheet Settings.
Do note that the additions that need to be done are the same in both cases: Add 1 to the value of the cell on the previous row, so there is no circular reference involved. There is a starting value provided in B2, and cells in B3 and downwards should use the data from the B cell in the previous row.
Also, note that I did try File->Spreadsheet settings and enabling circular reference computation with max 25 items, but this only fills in the first two cells (B3 and B4).
How can I solve this problem? I would prefer having something like ArrayFormula, where the formula only exists in a single cell. But copy-pasting would be acceptable as long as any new rows, inserted in between or added at the bottom, would get the same formula added in column B.
Will matching items always be consecutive? It seems that way since you're comparing each Item cell to the cell above it right in your formula logic. That breaks an [unwritten?] rule of spreadsheet normalization; values' addresses themselves generally should not be treated as data.
IF you're committed to it though, have you considered explicitly using location as a data source? Example:
=ARRAYFORMULA(IFS(
NOT(LEN(A3:A40)),,
ROW(A3:A40)-3-MATCH(A3:A40,A$3:A$40,0)<=VLOOKUP(VLOOKUP(A3:A40,Items!$A$2:$D,2,false),DataPerColor!$A$2:$B,2,false),ROW(A3:A40)-3-MATCH(A3:A40,A$3:A$40,0),
true,
))
Just like your formulas, all that does in English is:
for each row,
if there's no Item, don't output any ItemData,
if the number that belongs in this cell¹ is less than or equal to the lookup, print it,
otherwise, don't output any ItemData
But then what is ¹ "the number that belongs in this cell" and how can we calculate it without using column B? I abuse locations of things to get it. Looking down your row B, each number that appears is just:
this row's number,  minus  
the row where items start [always 3],  minus  
the row number [in just the Item rows] of the first row containing this row's Item
Using the second-to-last ItemC as an example: the first ItemC is the 16th item listing, and the one we're looking up… the "second-to-last ItemC" is in row 21 of the sheet. 21-3-16 = 2 …the number you wanted.
If you can stomach that, it's a single formula and does work according to your specifications.

How can I copy+paste rich text to just one column on Google Sheets?

I've googled this issue and have found plenty of information on how to "split text into different columns", but I want to copy+paste the text into just one column on the google sheet.
Herewith is a picture that shows what I'm getting (on the left), and what I actually need (on the right). I've tried CTRL+SHIFT+V but it doesn't work either. I did it in the past, but can't remember how.
Its a two part process.
1) Find the last column
Start with the cursor in the first column, press CTRL+Down. The cursor should jump to the next cell in the column. Press CTRL+Up, to move back to the top row. Move the cursor one column to the right and repeat.
It won't take long and you'll find that the cursor goes right to the bottom of the sheet; which means that there's no data in that column, and the Previous column is the last column.
2) Concatenate each row
Go to the first row of data, and create a Concatenate formula. Include every column from the first column (B) to the last column, regardless of whether you think there is data in those columns on this row.
Then copy the formula down to the very last row of data.
Then highlight the range, and Copy/Paste Values.
Depending on which are your first and last columns, your formula might look like this.
=CONCATENATE(C1,D1,E1,F1,G1,H1,I1,J1,K1,L1,M1)

How to use index match formula that automatically expands in Google Sheets

In Google Sheets I am using a filter function to pull in Names into column A and a Timestamp into column B. Every time a second occurrence of the name shows up into columns A & B of the list I want column C next to the prior occurrence to reference the new timestamp. In column D I will then calculate the difference from the names timestamp and the next occurrence of that same name.
Currently I am using the following formula:
=IFERROR(INDEX(B3:B,MATCH(A2,A3:A,0)))
If I drag this formula down it does what I need it to do, but due to how many rows are being added to the first two columns, rows are being added to the bottom of the sheet due to the filter and the formulas keep needing to be dragged down. The durations in column D are being calculated with the following formula, that automatically arrays the results and automatically expands with the filter results:
=IFERROR(ARRAYFORMULA(IF(C2:C="","",C2:C-B2:B)))
I would like my index match formula to do the same, but it seems I cannot use the index formula with an arrayformula.
I attempted to achieve this by using a vlookup combined with an offset for the range. The first row is giving me the result I want, but all the subsequent rows are not referencing the offset range, probably because the offset isn't changing with each new array result here is that attempt:
=IFERROR(ARRAYFORMULA(VLOOKUP(A2:A,OFFSET(A2:B,1,0),2,FALSE)))
Any ideas how this could be accomplished by placing a formula in one cell, or would this have to be accomplished with a script?
I have added an example spreadsheet of the current method HERE
Thanks in advance for any help.
Formula
Instead of
INDEX, MATCH and OFFSET
try the following formula
=ArrayFormula(IFERROR(VLOOKUP(
TRANSPOSE(VALUE(REGEXEXTRACT(QUERY(TRANSPOSE(
IF(FILTER(ROW(A2:A),LEN(A2:A))<TRANSPOSE(FILTER(ROW(A2:A),LEN(A2:A))),
IF(FILTER(A2:A,LEN(A2:A))=TRANSPOSE(FILTER(A2:A,LEN(A2:A))),
TRANSPOSE(FILTER(ROW(A2:A),LEN(A2:A))),
),)
),,2000000),"(\d+)"))),
FILTER({ROW(A2:A),B2:B},LEN(A2:A)),2,0)))
Formula description
This part creates a square matrix showing the row number of the value that matches if it's below of the current row:
IF(FILTER(ROW(A2:A),LEN(A2:A))<TRANSPOSE(FILTER(ROW(A2:A),LEN(A2:A))),
IF(FILTER(A2:A,LEN(A2:A))=TRANSPOSE(FILTER(A2:A,LEN(A2:A))),
TRANSPOSE(FILTER(ROW(A2:A),LEN(A2:A))),
),)
This part takes the smallest row that matches the current row (the next occurrence of the row value)
TRANSPOSE(VALUE(REGEXEXTRACT(QUERY(TRANSPOSE( ),,2000000),"(\d+)")))
This part returns the related value, if any, otherwise a blank:
IFERROR(VLOOKUP( ,FILTER({ROW(A2:A),B2:B},LEN(A2:A)),2,0)))

Excel Enter Value only IF Row contains specific text

I have this formula that I use to calculate lead-time for jobs which works great for what I have needed. Now my job data is going to change in each row and the data I need will not always be in the same column as it once was. What I need to do is add to my existing formula to only fill in the leadtime IF any cells in the row contain the text "COMPLETED", otherwise leave the cell blank. Can anyone help with this?
=(IF(ISBLANK(P1),"",(IF(P1-G1<7,IF(WEEKDAY(P1)>WEEKDAY(P1),P1-G1-2,P1-G1),(P1-G1-(ROUNDDOWN((P1-G1)/7,0)*2))))))
Test the value of a Match formula in another If statement to see if it's greater than 1, here's an example using your existing formula. This is for row 1 where the word 'COMPLETED' could be in columns B to Z:
=IF(IFERROR(MATCH("COMPLETED",B1:Z1,0),0)>0,"Completed",IF(ISBLANK(P1),"",(IF(P1-G1<7,IF(WEEKDAY(P1)>WEEKDAY(P1),P1-G1-2,P1-G1),(P1-G1-(ROUNDDOWN((P1-G1)/7,0)*2))))))

Resources