How to convert Excel formula to Google Sheets? - google-sheets

This code calculates a sum of string lengths in the range H1:V5 using G as a row index and C as a column index. It works perfectly in Excel:
{=SUMPRODUCT(LEN(INDEX(H1:V5,N(IF({1},ROW(G2:G5))),N(IF({1},C2:C5+1))))*ISNUMBER(G2:G5))}
But when I try it in Google Sheets it doesn't work although Google Sheets recognizes all commands. Is it possible to convert my formula to Google Sheets? Or maybe there is some workaround to get the same result there?
Open with Google Sheets returns incorrect result:
=ARRAY_CONSTRAIN(ARRAYFORMULA(SUMPRODUCT(LEN(INDEX(H1:V5,N(IF({1},ROW(G2:G5))),N(IF({1},C2:C5+1))))*ISNUMBER(G2:G5))), 1, 1)

Unfortunately the construct index...n(if({1}... is peculiar to Excel.
The vlookup function in Google sheets is very versatile and you can use that instead:
=SUMPRODUCT(len(vlookup(row(H1:K5),{row(H1:K5),H1:K5},C1:C5+2,false))*isnumber(G1:G5))

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})

Handle array size in Excel or Google Sheets

To create a 1x3 array in Excel or Google Sheets I can do:
={1,2, 3}
For example:
How would I create a multi-dimensional array, for example, a 3x3 array in Excel or Google Sheets?
Comma for columns, semicolon for rows (but it does depend on you language settings)
={1,2,3;4,5,6;7,8,9}
In Google Sheets and Excel, the union operator is ; so you can do:
'={1,2,3; 4,5,6; 7,8,9}
In Google Sheets you can use the following formula
=SEQUENCE(3,3)
Functions used:
SEQUENCE

How to input a discontinuous range into SUMIF in Google Sheets

I'm trying to do a SUMIF in Google Sheets, however since my input is a discontinuous range, it gives me an error. I am looking for a solution that does not require a Google Apps Script.
Works fine:
=SUMIF(A1:A9, "<>N/A")
Doesn't work:
=SUMIF(A1,A3,A7, "<>N/A")
Is there any method for doing a SUMIF with a non-continuous range as in the above non-working example?
try like this:
=SUMIF({A1; A3; A7}, "<>N/A")

How to loop over all sheets of a file in Google sheets?

I'm using Google sheets for storing some simple text. In a column (F) I have all names of sheets and I'm using the following to count occurrences of a certain string "aaa" in column C in all sheets:
SUMPRODUCT(COUNTIF(INDIRECT("'"&F3:F11&"'!C3:C200"),"*aaa*"))
It returns only occurrences in the first sheet. Any idea what is wrong?

Google Sheets equivalent for Excel's AGGREGAT formula

I am using Google Sheets and I need to implement following excel formula into my sheet.
https://docs.google.com/spreadsheets/d/1XzAYEezt2gNt_tdbxyZT-p6XwjNdhvUbt_9rBoABlhI/edit?usp=sharing
=IFERROR(INDEX(Formularantworten!B:B;AGGREGAT(15;6;ROW(Formularantworten!$B$2:$B$100)/(Formularantworten!$B$2:$B$100<>"")/(Formularantworten!$H$2:$H$100<>"");ROW(A1)));"")
Well if you want to match two columns and index a third column, finding the first match, you can do what you used to do in Excel before Aggregate came along:
=index(C:C,match(1,(A:A<>"")*(B:B<>""),0))
or
=index(C:C,min(if((A:A<>"")*(B:B<>""),row(A:A))))
But in Google sheets you have more options and are more likely to use something like
=query(A:C,"select C where A is not null and B is not null limit 1")

Resources