Sum in a index/match formula - arrays

Could you help me solve the following?
I want to return the total sum, not the first match that it finds. My first preference is have indexing and matching with the sum total, if this CAN'T be done then an if statement. I have include 'sheet1!' in the formula as it will be over 2 work sheets. Below is an example of the formula, the data will be over 4000 lines.
I can't post a image as I'm new but the array formula is
=INDEX(Sheet1!$G$4:$I$10,MATCH(A2&B2,Sheet1!$G$4:$G$102&Sheet1!$H$4:$H$102,0),3)
In the data that it is matching it is return the first result of many, I what the total amount.

Try to use following formula:
=SUMIFS(Sheet1!$I$4:$I$102,Sheet1!$G$4:$G$102,A2,Sheet1!$H$4:$H$102,B2)
or
=SUMPRODUCT((Sheet1!$G$4:$G$102=A2)*(Sheet1!$H$4:$H$102=B2)*(Sheet1!$I$4:$I$102))

Related

Excel - Return average of right three values in array

If I have a range in excel, say A2:I2, that is used to store the results from a monthly competition, what formula do I use in excel to return the average of the three most right values?
The formula needs to account for not all columns being filled, i.e. one player might have 5 results, one might have 9, and one might have 1.
Thanks
You can combinedly use TEXTJOIN() and FILTERXML() like below.
=AVERAGE(FILTERXML("<t><s>"&TEXTJOIN("</s><s>",TRUE,B2:J2)&"</s></t>","//s[position()>" & COUNTA(B2:J2)-3 &"]"))
Here "<t><s>"&TEXTJOIN("</s><s>",TRUE,B2:J2)&"</s></t>" will construct a valid XML string.
XPATH parameter "//s[position()>" & COUNTA(B2:J2)-3 &"]" will return last 3 nodes to calculate Average by AVERAGE() function.
COUNTA(B2:J2)-3 will detect how many nodes have before last 3 nodes so that we can return rest of nodes means always last 3 nodes by FILTERXML() formula.
More about FILTERXML() here by JvdV Extract substring(s) from string using FILTERXML
Edit: For google sheet you can use below formula.
=AVERAGE(FILTER(B2:J2,(COLUMN(B2:J2)-Column(A2))>IF(COUNTA(B2:J2)<=3,0,COUNTA(B2:J2)-3)))
If one has Microsoft365, you could also use:
Formula in K2:
=AVERAGE(INDEX(SORTBY(FILTER(B2:J2,B2:J2<>""),SEQUENCE(1,COUNT(B2:J2)),-1),SEQUENCE(MIN(3,COUNT(B2:J2)))))

averageifs w/ multiple average ranges in different columns

=IFERROR(AVERAGEIFS('Journal Input'!$AO$4:$AO$480,'Journal Input'!$O$4:$O$480,">="&F10,'Journal Input'!$O$4:$O$480,"<="&EOMONTH(F10,0)),"N/A")
This formula works but I need multiple average ranges added to this equation. My first average data range is AO but I have others in different columns (BB, BM, etc.) I would like to average along w/ AO. My multiple criteria's cover the beginning and end of the month F10. Perhaps an array is necessary? Any help is appreciated. Thanks Mike Link to picture example here
Here's a couple options. Enter this as an array formula (Ctrl+Shift+Enter):
=IFERROR(AVERAGE(IF(('Journal Input'!$O$4:$O$480>=F10)*('Journal Input'!$O$4:$O$480<=EOMONTH(F10,0)),CHOOSE({1,2,3},'Journal Input'!$AO$4:$AO$480,'Journal Input'!$BB$4:$BB$480,'Journal Input'!$BM$4:$BM$480))),"N/A")
Or, since it's the same conditions for all columns, you can average the AVERAGEIFS of each column (this doesn't need to be entered as an array formula):
=IFERROR(AVERAGE(AVERAGEIFS('Journal Input'!$AO$4:$AO$480,'Journal Input'!$O$4:$O$480,">="&F10,'Journal Input'!$O$4:$O$480,"<="&EOMONTH(F10,0)),AVERAGEIFS('Journal Input'!$BB$4:$BB$480,'Journal Input'!$O$4:$O$480,">="&F10,'Journal Input'!$O$4:$O$480,"<="&EOMONTH(F10,0)),AVERAGEIFS('Journal Input'!$BM$4:$BM$480,'Journal Input'!$O$4:$O$480,">="&F10,'Journal Input'!$O$4:$O$480,"<="&EOMONTH(F10,0))),"N/A")

Weighted average if row header contains

I'm looking for a formula that will return the weighted average of revenue for all the products that contain a "PASSDAYONE"revenue sheet
For now, I am filtering on "PASSDAYONE" then using "sumproduct' This example returns a weighted average of 37,23. Is there a way to have this result returned in one go with a single formula?
Try the following formula:
=SUMPRODUCT((ISNUMBER(SEARCH("PASSDAYONE",A2:A9))*C2:C9*B2:B9))/SUMPRODUCT((ISNUMBER(SEARCH("PASSDAYONE",A2:A9))*B2:B9))
Above formula will first search for the string PASSDAYONE in the range A2:A9 and if found will include in SUMPRODUCT formula.

Array Formula Index Match to Select Cell Based on Second, Third, and Fourth Minimum Value

I have a cell that currently uses an array formula to return the name associated with the minimum hours worked for all my employees. However, what I am trying to do now is write an array formula that lists the three next employees with lowest hours. I have written a formula similar to this in the past, but can't seem to get the two formulas to appropriately match up.
My current return minimum employee formula in G5:
={INDEX(A:A,MATCH(MIN(IF(B:B=G3,IF(C:C>=$G$2,D:D)))&G3,D:D&B:B,0))}
Here is an example of my data:
...and now I'm attempting to incorporate in into the following array formula that would return a list of qualifying results as I dragged it down a column:
={(IF(ROWS(G$7:G7)<=F$8,INDEX($A$2:$A$8,SMALL(IF(Employees!$B$2:$B$8=$G$3,ROW($A$2:$A$8)-ROW($A$2)+1),ROWS(G$7:G7))),""))}
Currently, this array formula is only set up to match on position title and not the other qualifiers that I need from my minimum employee formula. How can I mesh the two formulas correctly? Thank you for any and all help and please, let me know if you need any clarification.
The ideal array result would show Boris and two blanks in consecutive rows in the Next 3 Employees chart.
Set your page up like this:
With the ranking in column F.
Then it is a quick modification of the last formula. Instead of MIN we use Small. The k part of the small equation is the ranking number:
=INDEX(A:A,MATCH(SMALL(IF(B:B=$G$3,IF(C:C>=$G$2,D:D)),F5)&$G$3,D:D&B:B,0))
This goes in G5. Is confirmed with ctrl-shift-enter. Then copied down for rows.
If do not want the errors to show then wrap it in IFERROR:
=IFERROR(INDEX(A:A,MATCH(SMALL(IF(B:B=$G$3,IF(C:C>=$G$2,D:D)),F5)&$G$3,D:D&B:B,0)),"NO MATCHES")

Excel arrays count totals using criterias from multiple ranges (or sheets)

What I would like to do is to count the amount of lines that matches criterias to be verified in two arrays.
I can't use VBA, add new columns (for instance a new column with VLOOKUP formula) and preferably use arrays.
I have two separate ranges, each with a ID column for the identifier and other fields with data.
For instance, range 1:
Range 2:
If I had only to check the first range I would do:
={SUM((D4:D7="Red") * (E4:E7="Big"))}
But I don't know how to check also using data from the other range.
How, for example, to count the number of items that are Red, Big and Round by using both Ranges ?
Put this in the cell F4:
=IF((VLOOKUP(C4,$C$11:$D$12,2)="Round")*(D4="Red")*(E4="Big"),1,"")
Note that the behavior of VLOOKUP is that it finds the value up to the first parameter. Since there's no 1 in your second dataset, this first cell is going to show "#N/A", which I don't know how to solve, but when you extend this formula down to also compare the other sample data in the first set, the ID numbers 2 and 4 will show up as "yes" for you.
Edit: You wanted a count of this list. So after this, it should be easy to get a count of cells in this column using the COUNT function.
Try this array formula
=SUM((D4:D7="Red")*(E4:E7="Big")*ISNUMBER(MATCH(C4:C7,IF(D12:D13="Round",C12:C13),0)))
The last part is the added criterion you want - the IF function returns {2,4} [IDs where Data 3 is "Round"] and then you can use MATCH to compare C4:C7 against that. If there is a match you get a NUMBER (instead of #N/A) so you can then use ISNUMBER to get TRUE/FALSE and that feeds in to your original formula - result should be 2

Resources