Dynamic Helper Column? - arrays

I wish to create a helper cell using a dynamic array, Is this possible?
Normally I use a formula such as in this example =IF(A4="",C2,A4) which check if column A is blank and if so just copies the above value until a new value appears in column A.
However as shown in the image when I insert New rows the helper cell becomes broken.
For this reason I wanted to use a dynamic array to create the helper cell which should be able to handle rows inserted or removed.
The problem I have is that unlike a normal formula which you can just drag down, a dynamic array is looking at the values as a whole. Using =IF(A4:A40="","-",A4:A40) inserts a hyphen as shown in the image. Essentially I wish to replace the hyphen such that "For each value between A4:A40 check if blank and if true take the value in the above cell". In essence creating a dynamic helper column.

You can use the inexact form of Match to find the last row which is not blank, and then Index to take the value in column A from there:
=INDEX(A4:A40,MATCH(ROW(A4:A40),IF(A4:A40<>"",ROW(A4:A40))))
This sort of thing is done a lot in Google Sheets.
If you insert a row, the formula changes to
=INDEX(A4:A41,MATCH(ROW(A4:A41),IF(A4:A41<>"",ROW(A4:A41))))
and still works OK.

Related

Applying array formula for rows with existing data

I have trouble creating automation using Google Sheets. I use array formula for converting duration format from one column, to make it understandeable for Google Data Studio, however, my autiomation, when there's no existing project, needs to append a new row. But if there's an array formula applied to a column, it has created 0 values for 1000 rows, and my new row gets appended as 1001. How to fix that?
Maybe I could somehow limit the array formula to work only if there's data in the row?
I tried to find other variant of array formula from here, but none of these worked,
https://support.google.com/docs/table/25273?hl=en
I could use some help. Thanks before.
Here's my spreadsheet, that I'm working on
https://docs.google.com/spreadsheets/d/1zWxvwNhCExy7_9tvgJ0lo4nBmYac51NMqaqzh8kR4H4/edit?usp=sharing
Array formula applied to last column creates rows for non-existend data
use:
=ARRAYFORMULA(IF(E2:E="";;SECOND(E2:E)+MINUTE(E2:E)*60+HOUR(E2:E)*3600))

Excel array formula - managing data in table with dynamic height

I have a working array formula, which creates a list of values in column A. The length of the list depends on the input values of the formula and will vary over time. Values could be removed and added anywhere in the list, not necessarily at the end. Now in column B I want to manually add comments on the values in column A. When the length of the list changes, the values in column B don't move along with the values in column A, so they are not longer on the correct line. Is there a way to solve this?
You can try to use the OFFSET function for the dynamic variable.

Filter values from a list using values in another list

I have example data in the image shown, that uses the formula:
=FILTER(B3:B13,(B3:B13<>"D")*(B3:B13<>"H")*(B3:B13<>"J"))
to filter A-K such that D,H and J are removed from the returned list.
Is there any way using a formula that instead of having to specify the letters I wish to be removed can omit the values listed in another column (A in this case)? Ideally the solution will be just a formula but VBA could work too if anyone knows a solution for this.
Use ISERROR(MATCH()):
=FILTER(B3:B13,ISERROR(MATCH(B3:B13,A:A,0)))

Can I make an array out of a range of countif functions?

A truncated version of my data is in the form shown in the screenshot below: three columns of 5 unique names. The names appear in any order and in any position but never repeat in a single row.
My goal is to create an array that contains the number of times Adam appears in each row. I can fill down the formula=countif(A2:C2,$I$2) in a new column, or if I write the array manually for each row, it looks like:
={countif(A2:C2,$I$2);countif(A3:C3,$I$2);countif(A4:C4,$I$2);countif(A5:C5,$I$2);countif(A6:C6,$I$2)}
Where cell I2 contains "Adam". Of course, this is not feasible for large data sets.
I know that arrays are effectively cells turned into ranges, but my main issue is that the cell I'm trying to transform already references a range, and I don't know how to tell the software to apply the countif down each row (i.e. I intuitively would like to do something like countif((A2:C2):(A99:C99),"Adam") but understand that's not how spreadsheets work).
My goal is ultimately to perform some operations on the corresponding array but I think I'm comfortable enough with that once I can get the array formula I'm looking for.
try:
=ARRAYFORMULA(IF(A2:A="",,MMULT(IF(A2:C="Adam", 1, 0), {1;1;1})))

Nest an Excel Array Function In a Non-Array Function and Return an Array

I am trying to create a spreadsheet that will be used to provide quotes to customers. Some part-numbers apply to a single item. Some part-numbers are bundles of up to 4 items. I am trying to create a formula that returns all of the values associated with a given part-number.
Initially, I had two section in the quote - one that uses VLOOKUP to return part-numbers with single items and one that uses an array formula that returns an array of items.
The first formula is
=IF(ISNA(VLOOKUP(B12,PriceList,2,FALSE)),"",VLOOKUP(B12,PriceList,2,FALSE))
The second is
{=IFERROR(INDEX(Bundles!$B$2:$B$101, SMALL(IF($B$33=Bundles!$A$2:$A$101, ROW(Bundles!$B$2:$B$101 ) - 1,""), ROW() - 32 )),"")}
Screenshot showing results of first two formulas
Both work fine on their own. They rely on two data tables "PriceList" and "Bundles"
I want the sales reps to be able to type a part-number in column B and get the correct part descriptions - whether it is 1, 2, 3, or 4 items - to display in column C. I want them to be able to enter multiple part numbers on the same quote.
I tried to base this on the part number
=IF(LEFT(B29,4)="BUND",IFERROR(INDEX(Bundles!$B$2:$B$101,SMALL(IF($B$29=Bundles!$A$2:$A$101,ROW(Bundles!$B$2:$B$101)-1,""),ROW()-28)),""),VLOOKUP(B29,PriceList,2,FALSE))}
This works for bundled items, but repeats single items.
I would like to have a single data source (PriceList) and a single formula.
Partnumbers in Datasource
What I am now trying to do is use COUNTIF. For example if COUNTIF returns more than 1, use the array formula, else use the VLOOKUP formula.
I picture it to be something like
IF((COUNTIF(PriceList,Quote!B11)>1),"BUNDLE",IF(ISNA(VLOOKUP(Quote!B11,PriceList,2,FALSE)),"",VLOOKUP(Quote!B11,PriceList,2,FALSE)))
where "BUNDLE" is replaced by an array function. I can't seem to come up with the right array formula.
I tried
{=IF((COUNTIF(PriceList,Quote!B11)>1),IFERROR(INDEX(Bundles!$B$2:$B$101, SMALL(IF($B$11=Bundles!$A$2:$A$101, ROW(Bundles!$B$2:$B$101 ) - 1,""), ROW() - 32 )),""),IF(ISNA(VLOOKUP(Quote!B11,PriceList,2,FALSE)),"",VLOOKUP(Quote!B11,PriceList,2,FALSE)))}
This returns four rows of the same item for single items and nothing for bundles
I had thought about placing the array function in another cell and referencing that cell, but this does not help if the bundle contains more than one item.
Any thoughts or advice would be welcome.

Resources