How do I retain a formula but keep the cells empty until triggering data is input? - excel-2010

I'm new to Excel, so please be patient and kind.
In cell G3, I have a triggering date entered (example: 10/02/2018). In cell H3, I have entered the formula, G3+15, with the result being 10/17/2018. The formula in cell I3 is H3+15, with the result being 11/01/2018. This continues along the row until I reach 90 days from the triggering date of 10/02/2018.
When I copied the formula down the columns, the cells read across the row as 01/15/1900, 01/30/1900, etc.
How do I keep the formula set behind the scenes, so to speak, but keep the cells empty of data until the triggering date is entered in column G?
The triggering date will be entered as needed based upon specific events.
Thank you for reading and your suggestions.
Dana

You could use a simple IF statement. In H3 use the formula:
=IF(G3="","",G3+15)
This formula can then be dragged to the right/copied to the right to give you the number of columns you need.
The way this works is by validating the contents of G3. It is asking "Is cell G3 empty, if so, then return nothing; if not, do the math."

Related

How to Count cells since the last filled cell in a column, and repeat for each time a cell is filled

I have a tracking spreadsheet to track dry streak calcs for certain drops from a boss in a video game. I want to be able to easily see my dry streaks by having the sheet count the amount if boss kills since the last drop.
I have the following:
=IF(B2="",COUNTBLANK(B2:INDEX($B2:B,MATCH(FALSE,($B2:B=""),0))),"")+1
where column A is the boss kill count, and column B is filled if a drop is received.
the above formula works to an extent of what i want, but the order is upside down. I'd also like it to only show the "count since last drop" when a cell in column B is filled., rather than every cell showing it.
Example sheet
If column A is a sequence of numbers as depicted in the sample you can use formula 1 and formula 2 is stand-alone just based on column B. Please test them out.
formula 1:
=let(a,filter(A2:A,B2:B="drop"),byrow(A2:A,lambda(z,IF(offset(z,,1)="drop",z-xlookup(offset(z,-1,),a,a,,-1),))))
formula 2:
=let(a,filter(row(B:B)-1,B:B="drop"),byrow(B2:B,lambda(z,IF(z="drop",row(z)-1-xlookup(row(offset(z,-2,)),a,a,,-1),))))
Here you have another option that instead of looking for values it just makes a cumulative count.
=SCAN(0,B1:INDEX(B:B,ROWS(B:B)-1),LAMBDA(a,v,IF(v="drop",1,a+1)))
B1:INDEX(B:B,ROWS(B:B)-1) is a replacement for OFFSET so it is a bit more economic in resources
Then you can just hide the values when B is empty:
=INDEX(IF(B2:B="","",SCAN(0,B1:INDEX(B:B,ROWS(B:B)-1),LAMBDA(a,v,IF(v="drop",1,a+1)))))

Conditional formatting based on adjacent cell value even when the first adjacent cell in row is blank

I would like to colour cell C3 red, as the value is less than the next filled cell on row 3 (E3).
You need custom formula in the formatting rules for range C2:W.
And you can use the formula below for green:
=and(not(isblank(C2)),C2>index(filter(D2:$W2,arrayformula(not(isblank(D2:$W2))))),1,1)
And make another conditional formatting rule with the same range and change > accordingly for red.
Note that the equal case does not have formatting in your example.
To understand why, there are a few components at work. I'll give an outline in case OP or any passer-by wants one.
First is how conditional formatting in Google Sheet works. I will be brief here. The range we put in the rule is C2:W. Google Sheet will use the beginning cell in that range as a reference. For C2:W, the 1st cell is C2. In the formula, the cells are read in terms of relative position to that reference cell. So when evaluating formatting for cell C2, it treats the formula as is. But, for example, when evaluating formatting for cell C3, Google Sheet iterates all non-fixed ranges by 1 row. Another example: for D3, all non-fixed ranges are iterated by 1 row and 1 column.
Whenever the formula evaluates to true, the format will be applied -- although that is subject to further formatting if you have subsequent formatting rules which apply to the given cell.
Next are the components of the conditional formula.
not(isblank(C2)) checks for blank cells and makes the whole formula only true when the cell is non-blank.
For filter() usage, please consult official documentation. I will explain how filter() is applied to your example.
In our use, we are trying to rid of empty cells in the range that is on the same row as the cell in question and goes from the next column to column W. (I am using column W because there is no known end column in your image. Please adjust to your application accordingly.) Same row as C2 means row 2. Hence the digit 2 in D2:$W2. No $ sign for row because row index is meant to iterate through our range C2:W in the formatting rule. No $ sign for D because we mean 1 column next to the cell in question and the exact column index should iterate. We fix column W because the end column does not evolve and is thus not meant to iterate. Neglecting this will not particularly change the result in your example. However, it is good to be clear with the meanings.
arrayformula(not(isblank(D2:$W2))) produces a local row array whose cells are true/false that each represents whether the corresponding cell is non-blank. filter() in turn only keeps cells from D2:$W2 for cells in arrayformula(not(isblank(D2:$W2))) that are true.
We only care about the 1st non-blank cell. To retrieve the 1st cell from a (local) array, we use index(...,1,1). (That said, omitting index() also happens to work for the 1st cell in particular because when comparing a single cell with > or < to an array range, only the 1st cell of the array is used.)
Apply a conditional formatting to the range desired (starting from cell C2) using this formula:
=IF(C2="",FALSE,OFFSET(C2,0,AGGREGATE(15,6,(COLUMN(D2:W2)-COLUMN(D2)+1)/(D2:W2<>""),1))>C2)

How to offset importrange() within an arrayformula()

I have two Google Sheets (separate documents) that contain information, let's call them Master & Source. Within Source I have an undefined range of cells that are in sorted order by date that I need to display within Master. Master is intended to have links to all the various Source sheets, in normal operation, I'll have multiple of these, so I can view all of the quick information about all of the Source sheets displayed conveniently in Master. Master contains a date range that starts before and ends after the date range from within Source (to accommodate other date ranges from other Source sheets).
My goal is to create a single cell formula that can be copied and pasted for each Source that I need to view in my Master that would fill the cells in columns before and after the date range from Source with the string "No Class" and all the cells that match the date range from Source would simply be a copy/reference to the matching cell from Source. This is the formula I came up with:
=ARRAYFORMULA(if({A1:Z1;A1:Z1;A1:Z1;A1:Z1;A1:Z1}<importrange(Link!B4,"Source!A1"),"No Class",if({A1:Z1;A1:Z1;A1:Z1;A1:Z1;A1:Z1}>Link!N4,"No Class",importrange(Link!B4,"Source!A1:Z99"))))
Link!N4 = Start Date
Link!B4 = hyperlink to the google sheet `Source`
Amazingly, it works quite well, except for one major drawback: the array of values from importrange are relative to the cell that the formula is in - aka, the range from Source starts at Master!A1 rather than starting at the first column that has the same date as Source!A1.
This is a screenshot of the result of my formula in Master. *EDIT: No Class has conditional formatting to make the font color match the fill, so you can't see it in this screenshot, but they are the dark grey cells.
And another screenshot, this time of the Source I'm trying to view.
I realize this approach might not be the only way (or might not work at all) but each time I try something else it always comes down to the same problem: how do I dynamically start the importrange at the first column that matches the date from Source using a formula that is in the first cell?
I found an acceptable workaround. This is by no means a solution to the problem of trying to offset data within an array, but it allows me to get what I needed to be done. This code needs to be filled using the fill handle (blue square on the bottom right of the selected cell). I'm adding this here in the event someone gets in a similar situation and needs an alternative way to look at the problem.
=iferror(if(importrange(Link!$B4,"Source!A1")>A2,{"No Class";"No Class";"No Class";"No Class";"No Class"},if(importrange(Link!$B4,address(1,COLUMN(A3)-match(importrange(Link!$B4,"Source!A1"),$A2:$Z2,0),4,TRUE,"Source"))=A2,importrange(Link!$B4,address(2,COLUMN(A3)-match(importrange(Link!$B4,"Source!A1"),$A2:$Z2,0),4,TRUE,"Source")&":"&address(5,COLUMN(A3)-match(importrange(Link!$B4,"Source!A1"),$A2:$Z2,0),4,TRUE)),"No Class")),{"No Class";"No Class";"No Class";"No Class";"No Class"})
A2 is the date of the column in master I'm trying to import into, it changes as your drag the fill handle.
A3 is the cell that the formula is currently in
This works by first checking iferror (but I'll come back to that).
Then, if the date in the same column as the formula is less than the start date "No Class" fills the column (hides dates prior to start date)
ELSE If the date in the same column as the formula is the SAME as the date in the column of the Source (offset by the number of columns away from the start date) then fill the column with the corresponding column from Source (aka, this fills one column at a time, rather than importing the entire range at once).
(Back to iferror) An error is returned for any columns that come after the end date - so iferror fills those columns with "No Class"

How to use ARRAYFORMULA with OFFSET to previous row without getting circular reference error

Example sheet: https://docs.google.com/spreadsheets/d/14ma-y3esh1S_EkzHpFBvLb0GzDZZiDsSVXFktH3Rr_E/edit?usp=sharing
In column B of ItemData sheet, I have achieved the result I want by copying the formula into every cell in the column, but I want to solve this using ArrayFormula instead.
In column C I have achieved the same result using ArrayFormula. However, for addition, column C is referring to cells in column B, while column B is referring to cells in column B. I.e. every cell in column B is adding 1 to the cell on the row above.
If I select the C3 formula text and paste it into the cell edit field for cell B3 (to not screw up cell references during copy - I know I could make them static references, but this is not my problem), the cell gets an error value of
#REF!
Error
Circular dependency detected. To resolve with iterative calculation, see File > Spreadsheet Settings.
Do note that the additions that need to be done are the same in both cases: Add 1 to the value of the cell on the previous row, so there is no circular reference involved. There is a starting value provided in B2, and cells in B3 and downwards should use the data from the B cell in the previous row.
Also, note that I did try File->Spreadsheet settings and enabling circular reference computation with max 25 items, but this only fills in the first two cells (B3 and B4).
How can I solve this problem? I would prefer having something like ArrayFormula, where the formula only exists in a single cell. But copy-pasting would be acceptable as long as any new rows, inserted in between or added at the bottom, would get the same formula added in column B.
Will matching items always be consecutive? It seems that way since you're comparing each Item cell to the cell above it right in your formula logic. That breaks an [unwritten?] rule of spreadsheet normalization; values' addresses themselves generally should not be treated as data.
IF you're committed to it though, have you considered explicitly using location as a data source? Example:
=ARRAYFORMULA(IFS(
NOT(LEN(A3:A40)),,
ROW(A3:A40)-3-MATCH(A3:A40,A$3:A$40,0)<=VLOOKUP(VLOOKUP(A3:A40,Items!$A$2:$D,2,false),DataPerColor!$A$2:$B,2,false),ROW(A3:A40)-3-MATCH(A3:A40,A$3:A$40,0),
true,
))
Just like your formulas, all that does in English is:
for each row,
if there's no Item, don't output any ItemData,
if the number that belongs in this cell¹ is less than or equal to the lookup, print it,
otherwise, don't output any ItemData
But then what is ¹ "the number that belongs in this cell" and how can we calculate it without using column B? I abuse locations of things to get it. Looking down your row B, each number that appears is just:
this row's number,  minus  
the row where items start [always 3],  minus  
the row number [in just the Item rows] of the first row containing this row's Item
Using the second-to-last ItemC as an example: the first ItemC is the 16th item listing, and the one we're looking up… the "second-to-last ItemC" is in row 21 of the sheet. 21-3-16 = 2 …the number you wanted.
If you can stomach that, it's a single formula and does work according to your specifications.

Excel Enter Value only IF Row contains specific text

I have this formula that I use to calculate lead-time for jobs which works great for what I have needed. Now my job data is going to change in each row and the data I need will not always be in the same column as it once was. What I need to do is add to my existing formula to only fill in the leadtime IF any cells in the row contain the text "COMPLETED", otherwise leave the cell blank. Can anyone help with this?
=(IF(ISBLANK(P1),"",(IF(P1-G1<7,IF(WEEKDAY(P1)>WEEKDAY(P1),P1-G1-2,P1-G1),(P1-G1-(ROUNDDOWN((P1-G1)/7,0)*2))))))
Test the value of a Match formula in another If statement to see if it's greater than 1, here's an example using your existing formula. This is for row 1 where the word 'COMPLETED' could be in columns B to Z:
=IF(IFERROR(MATCH("COMPLETED",B1:Z1,0),0)>0,"Completed",IF(ISBLANK(P1),"",(IF(P1-G1<7,IF(WEEKDAY(P1)>WEEKDAY(P1),P1-G1-2,P1-G1),(P1-G1-(ROUNDDOWN((P1-G1)/7,0)*2))))))

Resources