How do I make Google Spreadsheet automatically divide a column into another column? - google-sheets

I'm making a spreadsheet that includes a long list of values, with a column that contains a total of values, and after that an average of the values in the row. I need the averaged column to always be 1/6 of the value in the summed column, but I can't figure out a way to make it automatically calculate it for me for each new row.
So far, I have been doing it all manually (type out all the values, manually add them together for the total, then divide by 6 myself for the average) but I'd really like to automate the math parts. I have not found a single way to properly do this - using "=DIVIDE(K2,6)" as a modified version of a suggestion on this other question (modified to use the column I'm actually putting the numbers in) does literally nothing, and I'd have to manually change and paste it into each row, which is actually harder and more tedious than continuing to do the math myself.
Here's an example image of what my columns look like. All the math is correct so far, I just want to automate it so I can type fewer numbers:
EDIT: Combined answers from Scott and Player0 is what worked! thanks for being patient with me! I was able to also use that to make the Sum column function automatically as well, so both columns are fully automated now! :D

You don't have to enter the formula manually on every line. 
Enter =K2/6 in cell L2; then select cell L2
and drag/fill it down to L12. 
(That means click on the dot in the lower right corner of the cell
and drag it down.) 
Or however far your sheet actually goes. 
That will automatically fill in L3 with =K3/6,
L4 with =K4/6, and so on.

use on row 2:
=INDEX(IFERROR(K2:K/6; 0)
also see: ArrayFormula of Average on Infinite Truly Dynamic Range in Google Sheets

Related

The subtraction from the number of each below of row on column AF. Get minus each others gradually row by row pointing upwards by formula in G.sheets

=byrow(AF3:AF;lambda(each;if(each="";"";SUMIFS(INDIRECT("AF"&row(each)&":AF");Indirect("O"&row(each)&":O");Indirect("O"&row(each));Indirect("K"&row(each)&":K");"CHECKOUT"))))
the formulas by #Martin!
From the above of the formulas by #Martin I try to modify a litle bit to ajustment to my kinda of my case I thought by trying to change the "SUMIFS" into "MINIFS" will comes out as I expected but well it's not. It's not working at all even close as I imagine it before. I was wrong because it's not for a MINUS function but in other hand it's like for another function to get a MINIMUM of number in a dataset.
What I want is to get a SUBTRACTION every each row of them SUBTRACT from the number of every below of each of them with the two conditions :
*first: based on the NAME on column "O".
*second: based on the criteria I desired and should be a certain value like CHECKOUT on column "K".
And I attached the link to explain more and than so you'll be understand what I mean is. And with the "expect output" in it hope can make this question more be clearly. Thanks in advance!
Please, feel free to edit My Example Quest of Spreadsheet
Isn't there anyway for you of differentiating that first values to be substracted from? (Or maybe eventually there would be more). For example putting "CHECKIN" to those values and "CHECKOUT" for all the ones that will diminish it. In that case you could modify that original formula and sum all the CHECKINs and substract from it all the CHECKOUTS
I've put it in a new tab of your spreadsheet, let me know if this could work for you:
=byrow(AF3:AF;lambda(each;if(each="";"";IF(OR(INDIRECT("K"&row(each))="CHECKIN";INDIRECT("K"&row(each))="CHECKOUT");sumifs(INDIRECT("AF"&row(each)&":AF");Indirect("O"&row(each)&":O");Indirect("O"&row(each));Indirect("K"&row(each)&":K");"CHECKIN")-sumifs(INDIRECT("AF"&row(each)&":AF");Indirect("O"&row(each)&":O");Indirect("O"&row(each));Indirect("K"&row(each)&":K");"CHECKOUT");""))))

Is there a way to copy certain parts of a formula down a column in Google Sheets?

I'm creating a Google Sheet documenting how many times a certain item appears in a video game with the formula in the D column (formatted to a percent):
=IFERROR(C2/SUM(C2:C51))
I want the "C2" cell to apply down the column (C3, then C4, you get the idea), but I want the "C2:C51" array to stay constant while the C2 part gets applied down the down the column. How could I modify the formula to do this? (I could manually edit the formulas all the way down, I only have 50 rows, but I think it would be helpful to learn for the future)
Try this:
=iferror(C2 / sum(C$2:C$51))
See absolute and relative references.
Alternatively, try this array formula that fills a whole column in one go:
=arrayformula(iferror(C2:C51 / sum(C2:C51)))

How do I get a cell to retain text, after the cell it pulls from changes text?

This question will have two parts. If you're willing to help me out, feel free to address whichever chunk you've got the time or interest for. Thanks in advance.
Assume there are two cells in a spreadsheet, the first (A1) has the text hello inside, and the second (A2) has =T(A1), so they now both say hello. If I want to change the text in A1, but want the text in A2 to continue to read hello, is there a way to automate this?
For some context, this is part of a larger project where I want to create a column of stock tickers that I like. Ideally, I could type the ticker name into a cell, check a box if I want to track it, and it would automatically add itself to a column. Where the first part of this question becomes relevant is that I would then move on to another stock, deleting the first ticker I wrote, but still wanting it in my column.
The second part of the question is about making the column. My instinct would be to use the =ARRAYFORMULA function, but that draws from a column to begin with, so I'm a little bit stuck.
Thanks
answer for Q1:
no, not possible unless you hardcode A2 as:
=T("hello")
or you use a script to remember your value but in that case, the A2 will host a custom function instead of the formula you mentioned
ofc what you are mentioning with those tickers, checkboxes and moving values around it's completely doable with a script
answer for Q2:
it depends on the formulae you use. not all formulas are supported under ARRAYFORMULA

How do I do a SUMPRODUCT in Google Sheets, but conditional on the text in both vectors?

The following spreadsheet shows the exercise submission status for 4 students. There are 4 exercises (1-4), but only 2 of them are homework (and thus graded) - they have a prefix 'H' in their name. A correct submission is marked "complete".
I'm trying to count, for each student, how many "complete" submissions he has, which are also homework. The right-most column is my desired result.
I tried all kinds of countifs, but couldn't get it. I have an ugly solution which uses SUMPRODUCT, but that requires substituting all the "complete" with 1's (which I'd rather not) + some more. I prefer a Google Sheets solution, but excel would work as well...
Have a heart and help out a teacher :-)
I suggest using mmult, which is a standard way of getting row totals from a matrix. As you mention, the first step is to convert each cell containing "complete" into a 1, then check the headers for presence of letter H.
=ArrayFormula(mmult((A2:D6="complete")*(isnumber(SEARCH("h",A1:D1))),transpose(column(A2:D6))^0))
I have tested this in Google Sheets, but it should work in Excel as well.
EDIT
(1) The easiest way to make the range accommodate changes is to put some upper limit on number of columns and make the references full-column, e.g.
=ArrayFormula(if(A2:A="","",mmult((A2:M="complete")*(isnumber(SEARCH("h",A1:M1))),transpose(column(A2:M))^0)))
You might want to move the total off onto another sheet:
=ArrayFormula(if(Sheet7!A2:A="","",mmult((Sheet7!A2:Z="complete")*(isnumber(SEARCH("h",Sheet7!A1:Z1))),transpose(column(Sheet7!A2:Z))^0)))
(2) To get the values as percentages, you can use countif:
=ArrayFormula(if(Sheet7!A2:A="","",mmult((Sheet7!A2:Z="complete")*(isnumber(SEARCH("h",Sheet7!A1:Z1))),transpose(column(Sheet7!A2:Z))^0)/countif(Sheet7!A1:Z1,"*h*")))
and format column as percent.
EDIT 2
To check for presence of H in headers but ignore h, use Find instead of Search, and regexmatch instead of countif:
=ArrayFormula(if(Sheet7!A2:A="","",mmult((Sheet7!A2:Z="complete")*(isnumber(find("H",Sheet7!A1:Z1))),transpose(column(Sheet7!A2:Z))^0)/sum(--regexmatch(""&Sheet7!A1:Z1,"H"))))
If you only want to include headers _starting_with H, change "H" in the regexmatch to "^H" as in #player0's answer.
if position of H columns is known, you can do simple:
=INDEX(IF(A2:A="",,ADD(D2:D="complete", E2:E="complete")))
if the number of columns and position of H's is unknown:
=INDEX(MMULT((INDIRECT("A2:"&ADDRESS(COUNTA($A:$A), COLUMN()-1))="complete")
*(REGEXMATCH(UPPER(INDIRECT("A1:"&ADDRESS(1, COLUMN()-1))), "^H.*")),
ROW(INDIRECT("A1:"&COLUMN()-1))^0))
update:
=INDEX(TEXT(MMULT((INDIRECT("A2:"&ADDRESS(COUNTA($A:$A), COLUMN()-1))="complete")
*(REGEXMATCH(UPPER(INDIRECT("A1:"&ADDRESS(1, COLUMN()-1))), "^H.*")),
ROW(INDIRECT("A1:"&COLUMN()-1))^0)/
SUM(1*REGEXMATCH(UPPER(INDIRECT("A1:"&ADDRESS(1, COLUMN()-1))), "^H.*")), "0.00%"))

Is there a way to use ARRAYFORMULA to find the most-recent even input of a column?

SOLVED EDIT
Thank you for the help. Solution here.
ORIGINAL POST
I have made a google sheet to describe the issue I am facing linked here (https://docs.google.com/spreadsheets/d/1yK6ZAX8BFnEqiuQO9HIxuY0l62ewDDccj-8EN1r2i2w/edit?usp=sharing).
I will also describe in words, below, the problem I am facing, along with the solutions I have tried.
The data of column A are random single-digit (0-9). I would like column B to show the most recent even number from column A, but only up to a specific row. That specific row is the row corresponding to the row of the cell in column B. In other words, in cell B7, I want to find the most recently entered even number of column A, specifically only on the range A2:A7 (A1 contains a column header).
This is actually a pretty simple formula, and I can get the desired outputs by simply checking if the value in a cell in column A is even and then returning the value of that cell if it is, or the output of the cell above if it isn't. So the formula would look something like: ​=IF(ISEVEN(A7),A7,B6)​
However, my problem is that the length of the data in column A will be growing as more data are entered, and my current solution of using the fill handle to copy the formula to new cells is inelegant and time-consuming. So my desired solution is to use an array formula entered into the first cell of column B (B2), capable of returning the same value as the other formula. The formula I tried to enter to perform this was the following: ​=ARRAYFORMULA(IF(ISEVEN(A2:A),A2:A,INDIRECT(ADDRESS(ROW(A2:A)-1,2))))​
However, as some of my previous work with arrays has taught me, not all formulas iterate as expected down the array. The formula seems to be able to return the correct output on lines which are already even, but it is unable to return the expected most-recently entered even number for all the other lines. It appears that the formula is not able to appropriately interpret the ​value_if_false​ argument of the ​IF​ formula.
I'm a little new to scripting, so I'm still trying to learn, but I also tried to dabble around with custom functions to no avail. I'm still wet behind the ears when it comes to coding, which is why I've been so lenient on the built-in formulas of Google Sheets, but I fear I may have reached the limit of what Sheets formulas can do.
I am open to trying new approaches, but my only real constraint is that I would really like for this to be a one-touch (or even better no-touch) solution, hope that's not too far beyond the scope of this issue. Any assistance would be much appreciated.
EDIT
After rubber-ducking the problem here, I went back and tried to use the OFFSET formula, hoping I could get it to play nicely with the array formula. Alas, I was unable, but I thought I should at least post my progress here for reference.
Attempt with offset
Still working at it!
Doing a vlookup on the row number seems to work for me
=ArrayFormula(if(A2:A="","",vlookup(row(A2:A),{if(iseven(A2:A),row(A2:A)),A2:A},2)))
Note: if there are no even numbers in range for some rows, it will produce #N/A for those rows.

Resources