Indirect cell reference in Google Sheets with variable input - google-sheets

I am trying to create a funnel analysis where I can play with the time delay between stages to see the impact. I need my formula to reference 1 row up and X columns over, where X is the number located in column B. This is what I have so far:
=(INDIRECT("R[-1]C[2]", false))/$C$16)
Except where you see C[2] - I need the 2 to be a variable fed by a fixed cell reference. I've tried every combination I can think of and have looked at a number of postings on INDIRECT cell reference formulas, but this seems to be one step further. It also seems like a fairly common type of "waterfall" analysis, so maybe I need a completely different approach?

You can use this sample formula:
=OFFSET(A2,-1,$B$1)/$C$16
Just remember to replace A2 with the current cell you are entering the formula from, and $B$1 with the location of the fixed cell reference.
Reference:
OFFSET()

Related

Google sheets, two-sheet dependent conditional formatting

My problem is probably trivial ... However, I was looking for similar problems and their solutions either do not work for me or I can not apply them.
I have 2 sheets - SheetA and SheetB. They are identical. I want to select every cell in SheetA that is no longer identical to Sheet B.
I was able to use (found here on Stack Overflow) such a function in conditional formatting:
= A1 <> INDIRECT ("SheetB! A" & ROW ())
It works if the range is column A. I know that I can apply this function to each column separately, but there is certainly a way that I can apply the same formula to the whole worksheet.
Will there be anyone who can show me the correct formula?
Edit: I tried to use above formula to every column... And my file become to work very slow... So whoever wants to do the same... think again.
After some tries I decided to move everything from SheetB to SheetA. I paste it a 1000 rows under data of Sheet A. Works fine without "indirect" function. No slow downs. It is not a perfect solution but it works.
But even after my problem is solved different way, I would like to know what is the correct formula for my problem... it might be useful for the future with smaller amount of data.
Solved ;)
You should be able to use the Address function to get the address of the current cell from its row and column:
=A1<>indirect("sheetB!"&address(row(),column()))
or for case-sensitive match:
=not(exact(A1,indirect("sheetB!"&address(row(),column()))))

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 Spreadsheet: SUMIF sum single cell iteratively for each met criteria

I am trying to sum a single value (in a single cell) for every cell that mets a certain criterion within a range. Consider the following scenario:
My objective is to sum the reference value 10 every time a cell is equal to V, giving a result of 30, in this case. I thought the formulae SUMIF might fit my requirements, so I tried assigning a single cell (the reference cell) as sum_range (more info here), but It only sums the value the very first time the criterion is met by a cell. So far, my approach looks like the following:
=SUMIF(A1:A7;"=V";A4) // Where A4 is '10'
I am aware that the proper usage of this function is to indicate a sum_range that at least equals the size of the range on which the criterion is looked up. The first logical solution would be to create an additional column next to the analysed range so that:
However, my current project does not allow me doing that, and I would rather prefer keeping the structure as in the first example. I would like to know if there exists any alternative to achieve what I am looking for in the first example.
What about:
=ArrayFormula(sum(if(A1:A7="V"; 10; 0)))

Resources