Google Spreadsheet a column mirrors a different columns values when it shouldnt be - google-sheets

Ive been working on a spreadsheet to examine something. I was converting a recursive formula into a linear one. The initial value or first state was 60. To get to the second state you 240. This is done by taking the previous state, doubling it, and adding 120. Which leads to the 3rd and 4th states of 600 and 1320. Now this base formula was clear enough that the (60+120)*2^(n-1)-120 accurately expresses it.
My second part comes from needing to add in the ability to decrease the costs while still staying true to the state. So the last formula only works when the cost reduction is 0. After considerable effort (I kept having minor rounding errors) I arrived at (ROUND(60-60*0.015*B$2)+(120-round(120*rounddown(B$2/3)*0.03,0)))*2^($A2-1)-(120-round(120*rounddown(B$2/3)*0.03,0)).
To test the formulas I created a table with the following values, with a2=1 to a5=4, and b2=0 to h2=6. Now I was using google spreadsheets to examine the information. When I populate the table I found that all the values were correct with the formula, except on G. On G the values are identical to F.
So to try and correct this I have deleted the information from the cells, deleted the columns, and even tried again in a new spreadsheet. But in all cases G=F when it should not. I cant figure out why I'm getting a duplicate column.
The information on row 3 is the values that it should be using.
The expected values are G4=55, G5=226, G6=568, G7=1252.

In case anyone wanted to know, I finally managed to solve the issue. I needed to round in one more place. The following is the formula that has worked for my current testing.
sum((ROUND(60-round(60*0.015*A$2))+(120-round(120*rounddown(A$2/3)*0.03,0)))*2^($A25-1)-(120-round(120*rounddown(A$2/3)*0.03,0)))

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");""))))

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

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

ARRAYFORMULA, OFFSET, and Circular Errors

I'm having trouble implementing a "Cash Out" feature in out party loot spreadsheet for my Pathfinder campaign. I keep running into circular references. The idea is that every member of the party gets their proportion of the party's liquid assets, unless they're in debt to the party. I'm using ARRAYFORMULA and MMULT to do these calculations, but I can't figure out how to reference the previous line in columns H through M from columns B through G. If I use OFFSET or VLOOKUP, I get circular reference errors. I just want to take the negative value of all positive numbers and put them in cells B through G, then everything else should work.
Here's a copy of the file. Feel free to mess around with it if you need to.
https://docs.google.com/spreadsheets/d/1PPkZWR4HP3jbWyWDJMskbo3K1Px4CHCurgNZh3MTS-M/edit?usp=sharing
Thank you for any help you can offer.
Before you ask, I wasn't able to figure out how to adapt this answer to my purposes: How to use ARRAYFORMULA with OFFSET to previous row without getting circular reference error
I figured it out. Just needed the right combination of the things I was already trying. The final formula was:
=ARRAY_CONSTRAIN(ARRAYFORMULA(SWITCH($T$2:$T,B$1,-($R$2:$R),"Cash Out",
IF(INDEX(MMULT(transpose(if(transpose(row($A$2:$A))>=row($A$2:$A),N(IF($T$2:$T = B$1,-($R$2:$R),$R$2:$R/6)), 0)),--(NOT(ISBLANK($R$2:$R)))),$A$2:$A-1)<0,0,
-(INDEX(MMULT(transpose(if(transpose(row($A$2:$A))>=row($A$2:$A),N(IF($T$2:$T = B$1,-($R$2:$R),$R$2:$R/6)), 0)),--(NOT(ISBLANK($R$2:$R)))),$A$2:$A-1))),
$R$2:$R/6)),COUNTA($R$2:$R),1)
The trick was using the MMULT method to generate the array of running totals above the cell I wanted to switch, then using INDEX and column A to specify which value I wanted. Using ROW() wasn't working. I've updated the sample file with the change.

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.

Google Sheets: Add value to total if a row condition matches for infinite column

I am attempting to make a Google Sheet that has a column for a rate and a value of that rate. Each night I am adding a new value to the bottom of this list so I want it to continue as an infinite list. What this sheet should do is look down the list of rates, if the rate matches a predefined rate, it should add the corresponding value to the total for that rate. I have four common rates that occur in no particular order and with some given value. I would like to total the values for each of those rates and give them in the totals section so each rate can be easily referenced.
Is there a way to do this using Google Sheets built-in commands? Pseudocode would be something like IF(A2:A = rate, add value in B to total). I know to make an infinite reading of a column by A2:A, but I don't know how to check each value as it goes through that column. I have attached a test spreadsheet with some sample values and the output that should be given by the formula. Thank you in advance for your help.
https://docs.google.com/spreadsheets/d/19k1DMipSsI9tWSjTXrVAPzPoaenWS6WYmlwe201_WQk/edit?usp=sharing
I managed to discover my own answer using the SUMIF statement. My code for the rate of .75 is ""=SUMIF(A2:A,"=.75",B2:B)"". I ran into some more trouble with the section for a different rate because I was having trouble saying not equal to .75 or 1 or 1.5 or 1.75. I solved this problem by completely bypassing it and adding the all the values and subtracting away the values already added. I would still like to know how to give the list of "ors" if someone could shed some light on this. But I now have a working solution regardless. I have updated the test sheet to show the solution.

Resources