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.
Related
I am utilizing a xlookup with indirect references function with certain date ranges to determine the range of rows to search in. With 3k rows of data and repeating values this helped me pair down to non-repeating values so I don't have an errant value from an earlier entry. The xlookup initially worked great when I manually inputted range of rows to search in but when indirect was introduced I am getting my error message I programmed (leading me to believe there isn't an error with my function)
When I utilize the direct references (meaning I'd have to change the date ranges directly in formula) it works great!
`=xlookup(T3,Statistics!F203:F215,Statistics!A203:215,"Not Scheduled",1,1)`
However when I use indirect to reference the specific range (so that I can adjust the date range over one cell and the reference rows recalculate) I get the error message I programmed.
`=xlookup(T3,indirect(Statistics!Q11&":"&Statistics!R11),indirect(Statistics!T11&":"&Statistics!U11),"Not Scheduled",1,1)`
Q11=F203
R11=F215
T11=A203
U11=A215
The correct answer lies in Row F205 which is within the ranges specified in the function.
Usually I figure these out or find a typo when utilizing my functions but I'll be honest and say this has me stumped. The references on the other page are identical. Just for note I also tried a Concateate function to combine the two cells before calling indirect with the same result. Any help would be greatly appreciated as this would add verification to a transportation system instead of double entry across two systems.
As far as I see it, what I think you're missing is the name of the sheet. You're referencing to the cells but not clarifying that the INDIRECT function has to look into "Statistics". Try adding it:
=xlookup(T3,indirect("Statistics!"&Statistics!Q11&":"&Statistics!R11),indirect("Statistics!"&Statistics!T11&":"&Statistics!U11),"Not Scheduled",1,1)
About that 1 after "Not Scheduled", are you sure you don't want an exact match only? Meaning to use a 0 instead of 1
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()
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.
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)))
I have my VLOOKUP with ArrayFormula working thanks to Adam's (AD:AM) brilliantly spelled-out solution (https://productforums.google.com/forum/#!searchin/docs/parallel$20lookup$20solution/docs/36A0epDlIdE/qnywZst0DioJ)
So in col J this is what I have:
=ArrayFormula(VLOOKUP(H2:H;ProductTable!A2:C;3*SIGN(ROW(H2:H));FALSE))
Works great. However, I would like to then take the returned value(s) from that formula in col J and multiply it against the Qty value(s) that are in row I.
Obviously I could add an extra helper column in col K...
=ARRAYFORMULA(I2:I*J2:J)
...but I was hoping to avoid adding yet another column to my Query results, especially since the returned results in col J have no visible purpose on the worksheet - they are meant to be used strictly for mathematical purposes only.
I've attempted multiple ways of slipping that formula into the ArrayFormula / VLOOKUP function in col J, but I've had no luck thus far.
Maybe it can't be done(?), or maybe I could just benefit from a fresh set of eyes looking at this issue.
Never mind. I'm not sure why this didn't appear to work when I had tried it before, but out of desperation I just walked away for a while, and then just re-tried everything again.
And this time I get the results that I was looking for:
=ArrayFormula(VLOOKUP(H2:H;Backend_Product!A2:C;3*SIGN( ROW(G2:G));FALSE )*I2:I)
(a bit of a DUH, so maybe I had originally referenced the wrong column or something)
The post you referenced is from 2011. I think that use case has been resolved since then.
I have a column using the formula =ArrayFormula(VLOOKUP(J$2:J,$C$2:$D,2,FALSE)). I created a check column with =VLOOKUP(J2,$C$2:$D,2,FALSE) which I dragged down a number of rows.
It appears that, in the array formula, J is being iterated just as it is in my dragged formula, while C:D are fixed. Both the original column and check column have the same result data so far as I've dragged the check column down.
Caveat: I did not do an exhaustive search or create a particularly clever test case. I just eyeballed a good heaping of rows of actual data.