When I do this with a Sumifs formula it works. But when I try with countifs connecting to a list of names I have and want it to read it does not work. What am I missing from the formula? The Sheet1!$E$6:$E$15 is where the list of names are located I want to look and count for specifically.
{=COUNTIFS(ROOM,'Attendance Output'!B10,SERIES,Sheet1!$E$6:$E$15)}
It looks like you want a count for when the named range ROOM is equal to 'Attendance Output'!B10 and the named range SERIES is any of the values in Sheet1!$E$6:$E$15.
As an array/CSE formula,
=SUM(COUNTIFS(ROOM, 'Attendance Output'!B10, SERIES, Sheet1!$E$6:$E$15))
Related
Below is my Workbook Sheet1
Am expecting sheet2 like below,
Total Item column (Using countifs I can get but Sub_Item1,2 and 3 How do I use Match Index in Excel)
Use countifs to count total_item =COUNTIFS($A$3:$A$12,D3). For sub items use below formula. Then drag down and right as needed. If need to handle errors then use IFERROR() function.
=INDEX($B$3:$B$12,AGGREGATE(15,6,(ROW($A$3:$A$12)-ROW($A$2))/($A$3:$A$12=$D3),COLUMN(A$1)))
I want to count the number of cells that meet two conditions:
sheet ABC's A2:A100 should be equal to the value of sheet XYC cell A8
the cell value in range D2:M100 = 1
Originally, I tried to use this formula:
=COUNTIFS(ABC!$A$2:$A$100,XYC!A8,ABC!$D$2:$M$100,1)
But this gave me error #VALUE
I then decided to use the following formula to count each column separately and add them together.
=COUNTIFS(ABC!$A$2:$A$100,XYC!A8,ABC!$D$2:$D$100,1)+
COUNTIFS(ABC!$A$2:$A$100,XYC!A8,ABC!$E$2:$E$100,1)+
COUNTIFS(ABC!$A$2:$A$100,XYC!A8,ABC!$F$2:$F$100,1)+
COUNTIFS(ABC!$A$2:$A$100,XYC!A8,ABC!$G$2:$G$100,1)+
COUNTIFS(ABC!$A$2:$A$100,XYC!A8,ABC!$H$2:$H$100,1)+
COUNTIFS(ABC!$A$2:$A$100,XYC!A8,ABC!$I$2:$I$100,1)+
COUNTIFS(ABC!$A$2:$A$100,XYC!A8,ABC!$J$2:$J$100,1)+
COUNTIFS(ABC!$A$2:$A$100,XYC!A8,ABC!$K$2:$K$100,1)+
COUNTIFS(ABC!$A$2:$A$100,XYC!A8,ABC!$L$2:$L$100,1)+
COUNTIFS(ABC!$A$2:$A$100,XYC!A8,ABC!$M$2:$M$100,1)
I am wondering if there are any other ways that allows me to shorten my formula?
Thank you.
You can use a boolean structure inside SUMPRODUCT() or just SUM() if your version of Excel supports dynamic arrays (ms365):
=SUMPRODUCT((ABC!A2:A100=XYC!A8)*(ABC!D2:M100=1))
How do I count between a date range using COUNIFS? The dates are set as columns The_Date_Start and The_Date_End.
My formula is
=COUNTIFS(Sheet2!C:C,[#Tel],Sheet2!A:A,"<="&[#[The_Date]])
I have tried something like the below but doesn't work
=COUNTIFS(Sheet2!C:C,[#Tel],Sheet2!A:A,"=>"&[#[The_Date_Start]],"<="&[#[The_Date_End]])
You can use this formula:
=COUNTIFS([ColToCount], ">="&[#End], [ColToCount], "<="&[#Start])
Note that all the ranges should be of same length. In your formula, they are of different lengths
I'm trying to write a formula using SUMPRODUCT, SUMIF, INDIRECT and a named range. My formula is:
=SUMPRODUCT(SUMIF(INDIRECT("'"&INDIRECT("EightiesNames")&"'!G8:HI8"),$A$2,INDEX(INDIRECT("'"&INDIRECT("EightiesNames")&"'!G9:HI300"),MATCH($A$1,INDIRECT("'"&INDIRECT("EightiesNames")&"'!E9:E300"),0),0)))
The formula goes through every worksheet in the named range and does a lookup to both the columns (looking up $A$2 in G8:HI8. note that $A$2 may occur multiple times in one worksheet) and rows (looking up $A$1 to E9:E300) before summing together all the return values with SUMIF/SUMPRODUCT.
The formula was inspired by the below simplified version but with SUMPRODUCT and INDIRECT layered in to allow it to perform the same function across multiple tabs.
=SUMIF(G8:HI8, $A$2, INDEX(G9:HI300, MATCH($A$1, E9:E300,0), 0))
See below for a more detailed description of the workbook.
Worksheets:
Sheet1 - houses a named range in cells B2:B7 {Name1, Name2, Name3, Name4, Name5, Name6}. The named range is called "EightiesNames"
Name1 - where the formula is located. The formula references worksheets Name1, Name2, Name3, Name4, Name5, Name6, basically all the worksheets in the named range.
There are three occurrences of "INDIRECT("'"&INDIRECT("EightiesNames")" - after the SUMIF, one after INDEX and after the MATCH. The first occurrence of the two INDIRECTs, works the way I want it to (when I evaluate the formula). It expands the INDIRECT("EightiesNames") into an array {"Name1";"Name2";"Name3";"Name4";"Name5";"Name6"}. The formula then proceeds to tack on the range "'!G8:HI8" after each "Name" - "'Name1'!G8:HI8";...;"'Name6'!G8:HI8".
However, for the INDIRECTs that occur after the INDEX and the MATCH, it does not return an array like the first one. On my computer, it returns "Name2" (returns "Name1" on my friend's), not sure why its different and why it returns those values instead of the entire array.
I'm not really sure how to fix this as the three INDIRECT formulas are identical but do not produce the same result. I also know INDIRECT formulas take up a lot of processing power so I'll gladly take alternatives. Any help/insight would be greatly appreciated! Thanks!
While a single formula solution is possible, it would be very complex, inefficient, and not robust at all. For this reason, I would suggest that you use a regular SUMIF formula for each worksheet, where it would be placed in the same cell for each of your worksheets, let's say B1, and then you could simply use SUM to get your total, for example =SUM('Sheet1:Sheet5'!B1).
However, if you would like to try a single formula solution, try the following formula that needs to be confirmed with CONTROL+SHIFT+ENTER.
Note that I have assumed that G8:HI8 and E9:E300 for each of your worksheets contain text values. If G8:HI8 contains numerical values, replace...
T(OFFSET(INDIRECT("'"&EightiesNames&"'!G8:HI8"),,COLUMN(INDIRECT("G8:HI8"))-7,,1))=$A$2
with
N(OFFSET(INDIRECT("'"&EightiesNames&"'!G8:HI8"),,COLUMN(INDIRECT("G8:HI8"))-7,,1))=$A$2
Also, if E9:E300 contains numerical values, replace...
T(OFFSET(INDIRECT("'"&TRANSPOSE(EightiesNames)&"'!E9:E300"),ROW(INDIRECT("9:300"))-9,0,1))=$A$1
with
N(OFFSET(INDIRECT("'"&TRANSPOSE(EightiesNames)&"'!E9:E300"),ROW(INDIRECT("9:300"))-9,0,1))=$A$1
Here's the formula...
=SUM(IF(T(OFFSET(INDIRECT("'"&EightiesNames&"'!G8:HI8"),,COLUMN(INDIRECT("G8:HI8"))-7,,1))=$A$2,N(OFFSET(INDIRECT("'"&EightiesNames&"'!G9:HI9"),TRANSPOSE(MMULT(TRANSPOSE(ROW(INDIRECT("9:300")))^0,IF(T(OFFSET(INDIRECT("'"&TRANSPOSE(EightiesNames)&"'!E9:E300"),ROW(INDIRECT("9:300"))-9,0,1))=$A$1,ROW(INDIRECT("9:300"))-9,0))),COLUMN(INDIRECT("G9:HI9"))-7,,1)),0))
Hope this helps!
I have a excel formula as below,
COUNTIFS($A$8:$A$14,$A8,$B$8:$B$14,$B8)
Here I want the criteria range to be calculated with a simple logic.
Instead of $A$14 I want this value to be calculated A$8+4 i.e. $A$14
In other words, it should get the current row and add 4 to be the criteria range for COUNTIFS
How can this be done is excel within the COUNTIFS formula?
Cheers
You could use =OFFSET(Cell Reference, Rows, Columns) within your formula to achieve this, for example:
=COUNTIFS($A$8:OFFSET($A$8,6,0),$A8, etc...)
Lets assume that the size of your range to be returned is stored in the cell D1.
=COUNTIFS($A$8:INDEX(A:A,ROW($A$8)+D1),$A8,$B$8:INDEX(B:B,ROW($B$8)+D1),$B8)
If you want the range to be defined as a certain number of rows after the current row as stated in your question, then still assuming the number of rows to be added is in D1, you would use the following:
=COUNTIFS($A$8:INDEX(A:A,ROW()+D1),$A8,$B$8:INDEX(B:B,ROW()+D1),$B8)
Expanding on Oliver's answer. The full format of OFFSET allows you to specify a whole range, not just one cell. OFFSET(Reference, Row Offset, Col Offset, Height, Width) so you could do:
OFFSET(A8,0,0,4,1)
This specifies the range A8:A11. In the COUNTIF
=COUNTIF(OFFSET(A8,0,0,4,1),A8,...)
Locking cells with $ works the same way within OFFSET if needed.
Try this:
=COUNTIFS(INDIRECT("$A$8:$A$" & 8+6),$A8,INDIRECT("$B$8:$B$" & 8+6),$B8)