I have a google sheet where I want to track the value of a cell over time and save the previous results. The standard =if() formula is actually if/else and will overwrite previous data. I searched for a way to stop the execution of a formula (to turn the if/else into a standalone if) along the lines of =if(today()=A1,value,Do Nothing). The following:
A B
1. 7/27/17 =if(today()=A1,value,"")
2. 7/28/17 =if(today()=A2,value,"")
3. 7/29/17 =if(today()=A3,value,"")
generates this on 7/27/17:
A B
1. 7/27/17 value
2. 7/28/17
3. 7/29/17
and on 7/28/17 it will be this:
A B
1. 7/27/17
2. 7/28/17 value
3. 7/29/17
Anyone know how to get to this on the 28th?
A B
1. 7/27/17 value
2. 7/28/17 value
3. 7/29/17
Turns out that you can do this in google sheets though you have to go into the settings to allow iterative calculations.
File -> Spreadsheet settings -> Calculation -> Iterative calculation [On]
Before this setting was changed the value of B1 =if(today()=A1,value,B1) would raise an error. With the setting it will now retain the previous value.
Related
I'll do my best to explain this. So, I want to use Arrayformula to autofill column based on a condition.
=IFERROR(QUERY(ARRAYFORMULA(IF((Research!$B$1:$B$100)="Yes",REGEXEXTRACT(Research!$A$1:$A$100,".*"),)),"WHERE Col1 is not null")).
It does what it's supposed to, but the problem comes if that condition changes at any point (so it's not true anymore) the value in the cell filled with the array will get deleted but will also offset all the other rows after it (same happens if I insert new row with 'Yes' value in between other rows, in my Research sheet from where I extract my data from).
Is there any way if I need to make changes to the condition in the sheet from where I extract data > and not offset everything else in the sheet where I use the array formula? (either delete the entire row if the value doesn't meet the condition anymore, or insert new row if it meets the condition (not just replace the value in previous cell in its spot, cuz then all the other fields are mismatched). I'm a beginner with excel, I hope that makes sense. Sheet ex
Condition in Main Sheet > Result in Array sheet
(these are the ok examples)
Changed value to yes for Agency 3 > Inserted in Agency's 5 place > and offsets everything after it
Please refer to the spreadsheet for my examples.
Method A: Separate the sheets of input and output
Method B: Input on Research and output on Initiative
Method C: Use Google Apps Script to 'avoid' offset upon change of Take? value. (example is not provided)
I have 3 rows in my Google sheet, that is stock, price, and total. so, I just use "multiple" formula for stock and price then put the value into the total row. but I don't want total row get an update or change the value whenever I change stock value.
Can someone help me?
Assuming you want cell A1 to only calculate its value once, you can put the following in cell A1. This tells the cell to just use its existing value if there is one (and it's not 0), otherwise run the formula.
=IF(A1<>0, A1, formula())
Since the cell is referencing itself, you will need to enable iterative calculation in File > Spreadsheet settings > Calculation.
I use something like the following for historical Google Finance data, since the value is never going to change, and sometimes Google Finance randomly returns an error. This will only run the GOOGLEFINANCE() formula until it returns a non-zero value without erroring.
=IF(IFERROR(A1)<>0, A1, GOOGLEFINANCE(...))
Google Sheets is not build to operate in such a manner. The most simple and fastest solution is to calculate what you need and then use CTRL + C and repaste with CTRL + SHIFT + V
use the copy paste value option per https://www.ablebits.com/office-addins-blog/google-sheets-convert-formulas-values/
Initially I was going with Grayson's solution, but this
=IF(IFERROR(A1)<>0, A1, GOOGLEFINANCE(...))
Places a FALSE on the cell until the result is placed.
I needed that to be empty, i.e. "" as whatever different from that (cell <>"") would trigger another cell to do another query/request.
I also needed the formula to be run depending on the trigger (the url in another cell). In this formula, if the trigger is placed after the formula has run, it won't trigger it.
So I have something like
=IF(AND(IFERROR(E53)<>0,E53<>""),E53, if(D53<>"",IMPORTDATA(D53),""))
<Update 2022-11>
While using this in arrayformula I noticed something that could be wrong.
IFERROR(E53)<>0 # Doesn't make sense.
It should be
NOT(ISERROR(E53))
And the whole thing in arrayformula (careful with AND/OR )
=ARRAYFORMULA( IF( NOT(ISERROR(E2:E)) * (E2:E<>"") ,E2:E, 'SOMETHING ELSE' ) )
I leave both versions in case someone spots errors in any of them.
<End of update 2022-11>
Explanation (It took me a while to understand it, so I could extend it):
D53 = myself
If I am nothing ("") or I am in Error (importdata not yet completed)
then
I am the result of -> If(D53<>"",IMPORTDATA(D53),"")
Which is:
If the cell before me is something different from "", run the importdata
with that cell as url, otherwise I am "" (nothing)
This achieves the goal of running the formula only once if the trigger is valid (the url on the cell before is there). Once the result is placed, it won't change.
If for whatever reason you need it to run again, you have to remove the formula and place it again.
Notes: If cellX has the result of an external fetch (IMPORTDATA for example) and on cellY=cellX, while on cellX you see "Loading ..." on cellY you will see a 0 (zero). I believe that explains why the other solution was comparing with 0.
I have two sets of data in columns A and B. I would like to pick the maximum value from column A which is also less than the value in the corresponding row in column B. I think I ought to be able to do this with the MAXIFS function but all the examples I can find compare against static values. I tried these options
=MAXIFS(A1:A10, B1:B10, "<")
=MAXIFS(A1:A10, B1:B10, A&"<"&B)
but neither of them worked as expected. In the first case, it is always 0 suggesting the condition is never met, in the second it gives an error.
I know that I could do this by creating a separate region of cells which first filter out the data that doesn't match the conditional and then simply pick the max from what remains but I'd rather do it in a single cell if possible.
Is there a syntax for this comparison and, if so, what is it?
To the best of my knowledge there isn't a way of getting it to work with MAXIFS.
You can write this
=maxifs(A:A,A:A,"<"&B:B)
and it will accept it, but it just uses the first value in column B and doesn't do a side-by-side comparison.
So you have to do it another way e.g. with a combination of Max and If:
=ArrayFormula(max(if(A:A<B:B,A:A)))
or you can use max with a filter or query:
=max(filter(A:A,A:A<B:B))
=max(query(A:B,"select A where A<B"))
=ARRAY_CONSTRAIN(ARRAYFORMULA(
IF(LEN(INDIRECT(ADDRESS(ROW(), COLUMN(B:B))))>0,
IF(INDIRECT(ADDRESS(ROW(), COLUMN(B:B)))<MAX($A$1:$A),
MAX($A$1:$A), LARGE(UNIQUE($A$1:$A), 2)), )), 1, 1)
I am trying to find a closest absolute value with index match. I looked at several other posts like here but what i am trying to do is a bit different as i want to add multiple search criterias.
As you can see , I am trying to get the absolute closest time for a specific person.
I am using the formula =index(C2:C21,match(F4,B2:B21,-1),match(E4,A2:A21,0)) and I had to copy column B in column C to make my 1st match work. The result is shown in G4. Unfortunately I am struggling to get the correct result.
Effectively I would like use the formula that was posted in the previous post (see link at the top) =INDEX(E2:E21,MATCH(TRUE,INDEX(ABS(D1:D21-I4)=MIN(INDEX(ABS(D2:D21-I4),,)),,),0))
with with a search criteria (the name of the person).
Any help would be much appreciated
Thank you
Thanks #avram
I still end up with some cases where the formula does not work. See below. in G6 and G7 i should get 10:25. (You can ignore column A)
Try this formula in G4,
=index(C$2:C$21, match(min(index(abs(index(C$2:C$21+(B$2:B$21<>E4)*1E+99, , )-F4), , )), if(B$2:B$21=E4, abs(C$2:C$21-F4), 1E+99), 0))
This will work in either google-sheets as a standard (non-array/non-CSE) formula or excel as an array (CSE) formula.
If anyone else wants to tackle this problem with a more elegant formula, you can copy the sample data from this publicly shared google-sheet.
Index match find closest value with multiple search criteria
Perhaps this may exempt a fourth person from retyping the same tired data that the op delivered in image(s).
A very simple approach using a "helper" column with data like:
We want the closest absolute match for larry to 10:15 AM. We enter larry in E1 and 10:15 AM in F1
Then in D2 we enter:
=IF(A2=$E$1,ABS(B2-$F$1),"")
and copy downward. (this is the absolute difference for larry) Finally in E2:
=INDEX(B:B,MATCH(MIN(D:D),D:D,0))
With bigger tables having more columns, it is very easy to add additional criteria if needed.
This answer uses Array Formulas which must be entered using CTRL+SHIFT+ENTER. It's kind of complicated, so I'll do my best to explain and will revise if necessary. Here's a screenshot:
Here is the formula in its raw form; names are entered in column A, Times in Column B.
=INDEX(B1:B7,MATCH(MIN(IF(A1:A7=D2,ABS(E2-B1:B7),"")),IF(A1:A7=D2,ABS(E2-B1:B7),"")))
As you might suspect, it uses INDEX/MATCH to get the job done, but the key is using an IF statement to generate both the search criteria and the array that the MATCH function searches within. Let's break it down.
Sec 1, Match Search Array
IF(A1:A7=D2,ABS(E2-B1:B7),"")
This creates the Search array for the match function. If the name in D2 (our criteria) is equal to the name in the search array, it return the absolute value of the difference between the criteria time and the time in the array we're searching. Otherwise it returns a blank value. Do not use 0 for this as it will skew the match result.
Sec 2, Match Search Criteria
MIN(IF(A1:A7=D2,ABS(E2-B1:B7),""))
This tells us the smallest value in the above array. We use this value as the search criteria in the MATCH function.
Sec 3, putting 1 & 2 Together
MATCH(MIN(IF(A1:A7=D2,ABS(E2-B1:B7),"")),IF(A1:A7=D2,ABS(E2-B1:B7),"")) This searches for the smallest abs difference defined in Section 2 within the array created in Section 1 and returns the row number.
Sec 4, Indexing the times
=INDEX(B1:B7,MATCH(MIN(IF(A1:A7=D2,ABS(E2-B1:B7),"")),IF(A1:A7=D2,ABS(E2-B1:B7),"")))
This returns the time value from column B in whatever row is identified by the Match function above.
Hopefully this all makes sense. Remember to enter it as an array formula.
I am working on a Sumifs that has 2 different criteria in Col B and the 3rd criteria in Col F.
If all 3 criteria are met then I am going to sum the values in Col Q.
I have this so far and it returns a 0. I tried to tweak it every way I am aware of and still no luck.
=SUMIFS($Q$4:$Q$2700, $B$4:$B$2700, "=AUS", $B$4:$B$2700, "=VCO", $F$4:$F$2700, "=TRB")
The formula you provided returns 0 every time because the value in B cannot be both AUS AND VCO, it's one or the other.
As far as I know (someone correct me if I'm wrong), there's currently no way to have a conditional statement in a single criteria range (e.g. "=AUS" OR "=VCO"). A workaround could be the following:
=SUM(SUMIFS(Q4:Q8,B4:B8,{"AUS","VCO"},F4:F8,"=TRB"))
This sums the values in Q if B equals either AUS OR VCO AND F equals TRB
The problem is that you reference $B$4:$B$2700 twice. Because this column can not possibly be both AUS and VCO Column Q will never be summed.
To make this work, add a new column next to column B. Make the value of cell C4 equal to the value of B4 (=B4) and drag this formula to cell B2700 (you can also just double click on the bottom right corner of the cell to make it auto-fill to B2700). You can then use this formula:
=SUMIFS($Q$4:$Q$2700, $C$4:$C$2700, "=AUS", $B$4:$B$2700, "=VCO", $F$4:$F$2700, "=TRB")
Remember to indicate if this answer worked!