Arrayformula inside an array in google sheets - google-sheets

I have the following formula in google sheets which works perfectly in the row 3.
=ArrayFormula(if(len($A$3:$A),vlookup($A$3:$A,'All records in progress'!A2:BE,{57,6,7,8,9,10,11,13,14,31,32,33},FALSE),""))
However, I would like to have the formula in the row 2 with the header so I was trying to create something like this:
={"Header"; ArrayFormula(if(len($A$3:$A),vlookup($A$3:$A,'All records in progress'!A2:BE,{57,6,7,8,9,10,11,13,14,31,32,33},FALSE),""))}
So I could have the word Header in the first row and the formula from the next row onwards. However, my formula is not working. Do you know if how I could achieve this?
Looking forward to your reply.
Cheers,

your vlookup returns 12 columns so you need:
={{"Header","","","","","","","","","","",""};
ARRAYFORMULA(IF(LEN(A3:A),
IFNA(VLOOKUP(A3:A, 'All records in progress'!A2:BE,
{57,6,7,8,9,10,11,13,14,31,32,33}, 0)), ))}

Related

Using SumProduct With Array Formula in Google Sheet

I have a problem to use sumproduct with array formula in Google Sheet which seems workable in Excel. The formula returns only 1st array value (E8*F8) which what I have to do is to get total sales price from everyday.
Below is the formula I used:
=SUMPRODUCT(ARRAYFORMULA(INDEX(E8:J8,,column(A1:C1)*2-1)),ARRAYFORMULA(INDEX(E8:J8,,column(A1:C1)*2)))
Below is the table view:
My Spread Sheet Link
Try this formula
=SUMPRODUCT(ARRAYFORMULA(FILTER(E8:J8, ISEVEN(COLUMN(E8:J8)))), ARRAYFORMULA(FILTER(E8:J8, ISODD(COLUMN(E8:J8)))))
Or even simpler
=SUMPRODUCT({E8,G8,I8}, {F8,H8,J8})

Copy a NB.SI formula into a Google Sheets sheet

I am turning to you today for help with a problem on Google Sheets.
I receive this data from a Google Sheets form: An answer (0 or 1) to 5 different questions.
I would like to calculate in column A (in green) the scores out of 5 for each row, as soon as a new row is added by the form.
I tried to use the ARRAYFORMULA() function but it does the count for all the cells in the range and not just row by row:
Do you have an idea to have a score out of 5 for each line of question and have it apply to the whole file as soon as a new line is added by the Google Form?
Thanks for your help
If you want to use COUNTIF (English correspondance for NB.SI), modify your formula to:
=ARRAYFORMULA(COUNTIF(IF(B1:F=1,ROW(B1:B)), ROW(B1:B)))
or for your regional settings:
=ARRAYFORMULA(NB.SI(IF(B1:F=1,ROW(B1:B)), ROW(B1:B)))
You can get a row-by-row sum with sumif() like this in cell A3:
=arrayformula( sumif( if(column(B3:F), row(B3:F)), row(B3:F), B3:F) )
This formula uses open-ended range references so it will create results all the way down to the end of the sheet. To limit that, use a range reference like B3:F100 instead.

Arrayformula not populating all other rows when using index+match

Sample data: https://docs.google.com/spreadsheets/d/10H7hToEek7XxXpPiAtlj6n58db_83Njdaxxspk4pIO8/edit?usp=sharing
Im trying to populate the 1st column of sheet 1 based on the data on sheet 2. VLOOKUP wouldnt work because im comparing the 2nd column of sheet 1 to the 2nd column of sheet 2 and vlookup will only allow it if im comparing to the 1st column of sheet 2. I tried index+match and it worked for 1 row but when I try to use arrayformula to populate all rows, it never runs for all the other rows.
Here is the index+match formula im using: INDEX(Sheet2!A2:A,MATCH(B2:B,Sheet2!B2:B,0))
Here is the formula I use with arrayformula:
=ARRAYFORMULA(INDEX(Sheet2!A2:A,MATCH(B2:B,Sheet2!B2:B,0)))
How do I make this run for all rows and if this won't work is there a better way to go about this?
per slippy101: =ArrayFormula(VLOOKUP(FILTER(B2:B,B2:B<>""),{Sheet2!B:B,Sheet2!A:A},2))
per Dazrin: =ARRAYFORMULA(IF(B2:B="",,VLOOKUP(B2:B, {Sheet2!B2:B,Sheet2!A2:A}, 2, FALSE)))
Both formula works, the problem arises because INDEX doesn't work with ARRAYFORMULA pointed out by Dazrin as well.

Using ArrayFormula to countif multiple columns and output the sum on each row

I've created a dense formula using COUNTIF and VLOOKUP across multiple columns, and I've currently set it up so that I have to copy/paste every formula. But I'd really like to be able to use arrayformula to write the formula once for each of the columns below, and have it render across at least 1000 rows. Is there a trick to writing this?
Column 1
=COUNTIF(VLOOKUP(F3,WarLinesValuesTypes,2,FALSE),"*Defense*")
+COUNTIF(VLOOKUP(G3,WarLinesValuesTypes,2,FALSE),"*Defense*")
+COUNTIF(VLOOKUP(H3,WarLinesValuesTypes,2,FALSE),"*Defense*")
+COUNTIF(VLOOKUP(I3,WarLinesValuesTypes,2,FALSE),"*Defense*")
+COUNTIF(VLOOKUP(J3,WarLinesValuesTypes,2,FALSE),"*Defense*")
Column 2
=COUNTIF(VLOOKUP(F3,WarLinesValuesTypes,2,FALSE),"*Offense*")
+COUNTIF(VLOOKUP(G3,WarLinesValuesTypes,2,FALSE),"*Offense*")
+COUNTIF(VLOOKUP(H3,WarLinesValuesTypes,2,FALSE),"*Offense*")
+COUNTIF(VLOOKUP(I3,WarLinesValuesTypes,2,FALSE),"*Offense*")
+COUNTIF(VLOOKUP(J3,WarLinesValuesTypes,2,FALSE),"*Offense*")
I also saw the StackOverflow post here (iterate row by row COUNTIF using ArrayFormula on Google Sheets), and tried to emulate it, but I am not getting it right. My sheet (https://docs.google.com/spreadsheets/d/1JR_eYvmf6YgW0CfzHrSR6dxF8RmyWhSKhqSpRnnbipk/edit?usp=sharing) shows the complex formula working correctly for both columns, as well as my failed attempt for 1 of those columns as a trial using arrayformula, mmult, and sign.
try:
=ARRAYFORMULA(MMULT(IF(REGEXMATCH(IFNA(VLOOKUP(
INDIRECT("F2:J"&COUNTA(B2:B)+1), 'Flattened Standard War Lines'!A:B, 2, 0)),
".*Offense.*"), 1, 0), TRANSPOSE(COLUMN(F:J))^0))

Preserving formula of a column when adding new rows in Google Sheets

I have a sheet which looks like this:
The C column is simply the product of column A and B. This formula is replicated in the entirely of column C, from row 2 to 1000.
However, if I add a new row between two existing rows, the formula is no longer there for that specific row. Looking around for solutions, I came across ArrayFormula. I changed my formula to the following:
=ARRAYFORMULA(IF(OR(A2="",B2=""),"",PRODUCT(A2:A, B2:B)))
However, this messed up the result. How can I solve this problem?
ARRAYFORMULA does not understand OR so you need to convert it into 0/1 logic:
=ARRAYFORMULA(IF(((A2:A="")+(B2:B="")), , A2:A*B2:B))

Resources