ArrayFormula for SUMPRODUCT of mismatched arrays - google-sheets

I have a grid of hours and an array of rates.
I'd like the array E2:E10 to be the sumproduct of the hours and the transposed RATES array.
Can someone help with the ArrayFormula?
I can easily do =SUMPRODUCT(TRANSPOSE(A2:D2),$I$2:$I$5) for E2 but it'd be more elegant to do an ArrayFormula that does the whole column if possible.

Using BYROW and LAMBDA there is no need for ArrayFormula():
=BYROW(A2:D10,LAMBDA(a,SUMPRODUCT(a,TRANSPOSE($I$2:$I$5))))

Related

ArrayFormula for Google Sheets using Sum and IF

So I have these formulas here
=if(J3="","",sum(J3,M3:N3))
=if(A1="","",index('SHEET1?'!F:F,match(A1,'SHEET1?'!E:E,0)))
I have been trying to find a way to get this as an array but I can't seem to find the solution that works best with this specific format. The problem is that if I do the array formula as is, it shows the sum of the whole range instead of giving the sum per row.
Any help is appreciated. Thank you!
SUM is not supported by ARRAYFORMULA, use + or MMULT
=ARRAYFORMULA(if(J3:J="",,J3:J+M3:M+N3:N)))
Alternative:
=ARRAYFORMULA(if(J3:J="",,J3:J+MMULT(N(M3:N),N(TRANSPOSE(COLUMN(M3:N)^0)))))
INDEX is not fully supported by ARRAYFORMULA, use VLOOKUP
=ARRAYFORMULA(IF(A1:A="",,VLOOKUP(A1:A,E:F,2,FALSE)))

Google sheets: separate and sum positive and negative numbers in column with vlookup

I'm trying to separate positive and negative numbers in a column and sum them up in 2 different columns based on a vlookup in google sheets.
I tried formulas like this:
=ArrayFormula(sumif($A$2:$A, ">0"&E2,$B$2:$B))
=ArrayFormula(sumif($A$2:$A, "<0"&E2,$B$2:$B))
But unfortunately they didn't work quite well.
(Please see an example attached.)
You can specify only one criterion in the SUMIF formula. So in G2 cell you sum all that is greater as 08858.
Use SUMIFS instead:
=SUMIFS(B:B,B:B,">0",A:A,E2)
Reference:
SUMIFS

Google Spreadsheets: CORREL() and MMULT() with missing cases/blanks

So I've got the following formula to correlate two ranges:
=ROUND(CORREL(ARRAYFORMULA(MMULT('E0:Sample'!$D$2:$AY,TRANSPOSE(SIGN(COLUMN(('E0:Sample'!$D$2:$AY)))))),FILTER(OFFSET('E0:Sample'!$D$2:$D,0,ROW()-2),NOT(ISBLANK(OFFSET('E0:Sample'!$D$2:$D,0,ROW()-2))))),3)
The formula works fine, as long as there are no blanks in 'E0:Sample'!$D$2:$AY. Otherwise the error message Function MMULT parameter 1 expects number values. But '' is a empty and cannot be coerced to a number. is thrown.
I´ve tried to filter() for empty rows, but the filter-function won't work since the ranges differ.
How do I solve this without the best way?
Thanks!
It's difficult to test your complete formula, but I did a test on a mini-version of matrix multiply and it seems that you can use the N function the same way as you can in Excel. Here is my mini-test:-
=ArrayFormula(MMULT(n(B1:G1),n(A1:A6)))
where both ranges contain a mix of numbers, alphas and blanks. Non-numeric cells are treated as zeroes.
Reference
I'm not totally clear about the context for this - I think you're trying to get the row sums from your large 2D array by using the mmult - if this is correct I think my answer is OK because the blanks would contribute nothing to the sums. Since CORREL ignores blanks in the second range, you don't need to filter at all?
I did eventually set up some test data for your formula, and my formula ended up like this:-
=ROUND(CORREL(ARRAYFORMULA(MMULT(n('E0:Sample'!$D$2:$AY),TRANSPOSE(SIGN(COLUMN(('E0:Sample'!$D$2:$AY)))))),OFFSET('E0:Sample'!$D$2:$D,0,ROW()-2)),3)

Google Sheet Arrayformula with multiple mathematical functions

How would I go about formatting an arrayformula for this?:
=$D10*(sum($F10:$I10))
I've tried a few different ways but none of them work. I have a bunch of rows with that formula (where of course the row number matches, so for example:
=$D10*(sum($F10:$I10))
=$D11*(sum($F11:$I11))
=$D12*(sum($F12:$I12)) etc...
I need this formula in each row but I'm trying to figure out an arrayformula so that it works when I add or subtract rows.
Thanks for your help!
UPDATE************************************************************************
I've just figured out that =arrayformula(D7:D*(F7:F+G7:G+H7:H+I7:I)) works but I might need to add and subtract columns too. Is there a way to make it work with sum()?
I believe MMULT can be a good alternative:
=ArrayFormula(if(len(D2:D), D2:D*mmult(N(F2:I),transpose(column(F2:I2)^0)),))
Change ranges to suit.
The best way to solve math problem is to split it.
You have two multipliers: D x sum(F:F)
The first task is to make ArrayFormula with D. It's simple:
=ArraFormula(D10:D1000)
And the hard part is to make ArrayFormula with sum. This part was already asked and answered here by AdamL. In your case:
=ArrayFormula(SUMIF(IF(COLUMN(F1:I1),ROW(A10:A1000)),ROW(A10:A1000),F10:I1000))
And your final formula is
=ArrayFormula(D10:D1000 *
SUMIF(IF(COLUMN(F1:I1),ROW(A10:A1000)),ROW(A10:A1000),F10:I1000))

How can I use nested formulas in the ARRAYFORMULA function in Google Sheets?

I need Google Sheets to compute sums for each row using the arrayformula() function.
I know I can manualy enter somthing like;
=ARRAYFORMULA(A:A + B:B + C:C)
but I need the use of the functions to do it.
I've tried many things including;
=ARRAYFORMULA(sum(A:A,C:C))
Here is a sample file that I could use help with.
This formula works in cell G3 of your test sheet:
=ArrayFormula(mmult(ARRAYFORMULA(IF(ISBLANK(A3:C),0,A3:C)),sign(transpose(column(A3:C)))))
I've used a custom format to hide the zero values on the empty rows as well
Formulas
Addition (SUM)
QUERY function
=QUERY(A3:C20,"Select A+B+C Label A+B+C ''")
Concatenation
& operator
=ArrayFormula(J3:J20&K3:K20&L3:L20)
CONCAT function
=ArrayFormula(CONCAT(CONCAT(J3:J20,K3:K20),L3:L20))
Explanation
Besides ARRAYFORMULA, Google Sheets has QUERY, FILTER, ARRAY_CONSTRAIN, among other functions that could help you to handle array operations. Take a look to Function List to have the complete list. Also could be very helpful that you to take a look to Using arrays in Google Sheets.

Resources