Search code examples
google-sheetsgoogle-sheets-formula

Adding items to an array based on a list


I'm trying to make a formula that goes into A2 to replicate the array of cells on the left block. (currently its manually entered)

On the right I have a QUERY that pulls up all rows from a trade log tab and shows only trades where items have been added and at what price. I want to add a number of cells for Added in R3 in the first row, at the price to the left in Q3. Then for it to go to the next line and add those in.

Any pointers as what to look at to do this?

enter image description here


Solution

  • Here's a possible solution:

    =ARRAYFORMULA(IFNA(WRAPROWS(REDUCE(TOCOL(,1),SEQUENCE(COUNT(Q3:Q)),LAMBDA(a,i,{a;IF(SEQUENCE(INDEX(R3:R,i)),INDEX(Q3:Q,i))})),15)))