Using an array formula in Excel with sumif - arrays

I'm trying to make an array formula work to sum data based on vertical and horizontal criteria in Excel. Here is the formula I've tried, but it's returning a #NAME? error.
=arrayformula(SUM(IF('By day'!$C$3:$GB$3='By week'!C$1,IF('By day'!$B$4:$B$395='By week'!$A3,'By day'!$C$4:$GB$395))))
Can anyone suggest what I need to change to make this work? I'm new to array formulas so any help would be greatly appreciated. I tried just pressing Enter and pressing Ctrl + Enter, and neither worked.
I also tried this, which is correctly summing based on the vertical range ('By day'!$B$4:$B$395) but doesn't take account of the horizontal range ('By day'!$C$3:$GB$3) - i.e. it simply sums all columns that match the vertical range:
=SUM(IF(('By day'!B4:B401='By week'!A3)+('By day'!C3:GB3='By week'!B1),'By day'!C4:GB235,0))
Thanks in advance!

Related

Excel - Find a Cell in an array and its location

Looking to figure out how to determine the address of a cell in an array based on a previously determined max value. See the attached picture:
What I'm looking for in this image is the cell directly above the minimum value of 192.02. Total minimum value is determined by finding the minimum across the row, then down in a column. I need to figure out how to bolt on a formula that will essentially find that location and move up one cell. Duplicates aren't an issue - the first match is sufficient.
Haaaaa... I found out a method using SUMPRODUCT, but it wasn't working out for me, reporting a circular reference. I couldn't figure out what the hell the issue was until I realized the "row check" formula extended infinitely to the right and I'd put the formula in a cell in that area - thereby making it an infinite loop. Embarassing.
The method I found was this, incidentally:
=SUMPRODUCT((K6:M20=H24)*(COLUMN(K6:M20)))
=SUMPRODUCT((K6:M20=H24)*(COLUMN(K6:M20)))
Where H24 is my minimum value and K6:M20 is the range. Then you can use INDIRECT with these values to get the value of that cell. In my case, I'd use
=INDIRECT(ADDRESS(ROW-1,COLUMN),TRUE)
To find the cell directly above that value. Sometimes just posting a question can solve it for you, haha.

Get value of same cell from multiple sheets

I'd like to get the value of cell A1 from multiple tabs in my sheet. I attempted to use INDIRECT, only to be reminded that it wouldn't work in an ARRAYFORMULA. Is there some sort of "makeshifty" formula that would do the same thing?
This is what I originally attempted:
=ArrayFormula(IF(LEN(A2:A),INDIRECT(A2:A&"!A1"),))
Column A is a select list of the tab names in my sheet. So the first instance works, but of course, it doesn't populate down the column as I had hoped. I realize I can just copy the formula down the column, but some type of an ARRAYFORMULA would be ideal as I add rows to the list.
I found this answer, but don't see how I could apply it to my situation.
I also found this answer, but thought since it's 2.5 years old, maybe someone has discovered a clever way to avoid the drag of copying.
Answer:
You need to do this with a script or by using the drag method - INDIRECT uses a string reference and so can't be used with an array.
More Information:
Unfortunately for the user of INDIRECT with ARRAYFORMULA, a discovery of a clever method isn't the issue - the limitation of what can be done with only formulae that is the root of this problem.
Setting up a custom function:
From the Tools > Script editor menu item, you can create scripts. An example custom formula that you could use would be as follows:
function ARRAYINDIRECT(input) {
var ss = SpreadsheetApp.getActiveSpreadsheet();
return input.reduce(function(array, el) {
if (el[0]) array.push(el[0])
return array;
}, []).map(x => ss.getSheetByName(x).getRange("A1").getValue());
}
Make sure to then save the script with the save icon.
In your Sheet you can then call this custom formula as so:
=ARRAYINDIRECT(A2:A)
Rundown of the function:
Takes the input range from where the formula is called - in this case A2:A
Reduces the input to remove all cells that are empty
Maps the name of the sheet which is stored in the cell to the value in A1 of the sheet it references
Returns an array to output
References:
JavaScript Array reduce() Method
INDIRECT - Docs Editors Help
ARRAYFORMULA - Docs Editors Help

Google Sheets Function replication

Is it possible to have a function that contains two ranges and you want to drag that formula across multiple cells but only have one of the ranges auto-advance while keeping the other function the original without advancing?
Here is the function
=IFNA(JOIN(", ", FILTER(Input!A5:A31, Input!JZ5:JZ="V")))
I want to drag this across multiple cells in a row, however, I only want the Input!JZ5:JZ="V" portion to advance to Input!KA5:KA="V" and leave the Input!A5:A31 the same due to that's the location of the information I am looking for and doesn't change.
Currently, both will advance to the next cell and so I am having to go back and fix each one and I have about 300 of these I need to do.
Any suggestions, please?
sure, lock it down with $ symbols. try:
=IFNA(JOIN(", ", FILTER(Input!$A$5:$A$31, Input!JZ5:JZ="V")))

Excel: Sumproduct, input of array and range not working

I am trying to do a sumproduct such as
=SUMPRODUCT(A1:A8,{8,7,6,5,4,3,2,1})
but it give #VALUE! error,
While it is gives a valid value for
=SUMPRODUCT({8,7,6,5,4,3,2,1},{8,7,6,5,4,3,2,1})
Or
=SUMPRODUCT(A1:A8,A1:A8)
According to my understanding it only works if all inputs are of Range or Array type, but not when there are both. Is there any way to make it work?
or you can use ; for vertical array :
=SUMPRODUCT(A1:A8,{8;7;6;5;4;3;2;1})
{8,7,6,5,4,3,2,1} is horizontal array similar to horizontal range like A1:H1 which will not work well with the vertical range A1:A8
I can't test it, but another way can be with the Row function:
=SUMPRODUCT(A1:A8,9-Row(A1:A8))
=SUMPRODUCT(TRANSPOSE(D3:D10),{8,7,6,5,4,3,2,1})
EDIT: Above code works if entered as array forumla
=SUMPRODUCT(D3:D10,TRANSPOSE({8,7,6,5,4,3,2,1}))
works without entering as array formula.

Google Spreadsheet array not working

I'm not sure what I missed as my arrays are not working. Here's the link:
https://docs.google.com/spreadsheets/d/1_pPSRjEnKv10mDR8LICVvVv7jgXVBJ1aWZ8KrdEIKd4/edit#gid=0
Please check highlighted in green.
Thanks
Im not sure how to explain why it doesn't work because there are a list of things - various ways in which array formula operates - but I would like to suggest to you to use regexextract instead of search: I created the two formulas for is profile and is live, hopefully I can try to explain what the pieces do:
in column Y:
=arrayformula(if(arrayformula(if(istext(regexextract(C2:C,"automated")),1,0))+arrayformula(if(or(istext(regexextract(C2:C,"clinic profile")),istext(regexextract(C2:C,"dr profile"))),1,0))=2,1,0))
in column Z:
=arrayformula(if(Y2:Y=1,if(istext(regexextract(C2:C,"live")),1,0),0))
Basically instead of using the search - regexextract will find your search terms anywhere in that text and it works well with array formula, then using the if and istext to give it a true of false value of 1 or 0.
if the value is not found in that corresponding cell, it would in theory return #N/A if it was in an individual cell - but if the value is there the regexextract would return that value to you, which why the istext works
By the way if Im confusing you , then if you want to change your sheet to be editable by anyone I can jump in and show you what I did..

Resources