Countifs or Pivot table

waqasbutt

New Member
Joined
Apr 7, 2015
Messages
22
Hello All,

Need your help, I am trying to use countifs function to get the results (refer below second table) but countif does not works.
I want to count how many issues in a month and results as well. As each month, different issues occurs and I want month count.

I tried Pivot table but there are two issues:

First, if I ungroup it combine months results e.g Dec 18 has 10 records and Dec 19 has 5, it shows me 15.
Second if I do not ungroup them it shows me records with respective months but for results column I only need records with Pass. E.g in same pivot table, I need total records for issues but for results only having Pass. I need this for graph where record will be bar and results will be trend line (ideally I need %).

I tried countifs because it is much flexible where I can search based on specific column and but somehow it does not works.

Any help will be appreciated.

DATA
-----
ItemDateResults
Issue115/12/2019 17:49:57Pass
Issue215/12/2019 17:49:57Pass
Issue314/01/2019 18:41:36Pass
Issue414/01/2019 19:36:39FAIL
Issue515/01/2019 9:18:06Pass
Issue615/01/2019 9:37:55Pass
Issue715/01/2019 9:53:06Pass
Issue815/02/2019 9:51:50Pass
Issue915/03/2019 11:51:52Pass
Issue1015/03/2019 11:59:55Pass
Issue1115/04/2019 12:27:17Pass
Issue1215/05/2019 9:08:04FAIL
Issue1315/06/2019 9:13:19FAIL
Issue1415/12/2018 9:31:44Pass
Issue1515/12/2018 9:31:44Pass


Results I am looking for;
MonthIssuesResults (ONLY PASS)
Dec-1822
Jan-1954
Feb-1911
Mar-1922
Apr-1911
May-1910
Jun-1910
Dec-1922


Regards,
Waqas
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Try this

In the column of the month put the day 1 of each month ex: 1/Jan/2019 in format you can change to Jan/2019

Dante Amor
ABCDEFG
1ItemDateResultsMonthIssuesResults (ONLY PASS)
2Issue115/12/2019 17:49Pass01-dic-1822
3Issue215/12/2019 17:49Pass01-ene-1954
4Issue314/01/2019 18:41Pass01-feb-1911
5Issue414/01/2019 19:36FAIL01-mar-1922
6Issue515/01/2019 09:18Pass01-abr-1911
7Issue615/01/2019 09:37Pass01-may-1910
8Issue715/01/2019 09:53Pass01-jun-1910
9Issue815/02/2019 09:51Pass01-dic-1922
10Issue915/03/2019 11:51Pass
11Issue1015/03/2019 11:59Pass
12Issue1115/04/2019 12:27Pass
13Issue1215/05/2019 09:08FAIL
14Issue1315/06/2019 09:13FAIL
15Issue1415/12/2018 09:31Pass
16Issue1515/12/2018 09:31Pass
Hoja1
Cell Formulas
RangeFormula
F2:F9F2=SUMPRODUCT(($B$2:$B$16>=$E2)*($B$2:$B$16<=EOMONTH($E2,0)))
G2:G9G2=SUMPRODUCT(($B$2:$B$16>=$E2)*($B$2:$B$16<=EOMONTH($E2,0))*($C$2:$C$16="Pass"))
 
Upvote 0
Two things to mention:

1) Generally, COUNTIFS works faster than SUMPRODUCT. In addition, entire columns can be used in COUNTIFS:

=COUNTIFS(B:B,">="&E2,B:B,"<"&EOMONTH(E2,0)+1)
=COUNTIFS(B:B,">="&E2,B:B,"<"&EOMONTH(E2,0)+1,C:C,"Pass")

2) The formulas suggested in Post # 2 will not count end-of-month dates with timestamps beyond 0:00:00, for example 31/01/2019 01:23:45
 
Upvote 0
@Tetra201, good catch.

Here the formula corrected with another approach:

Dante Amor
ABCDEFG
1ItemDateResultsMonthIssuesResults (ONLY PASS)
2Issue115/12/2019 17:49Passdic-1822
3Issue215/12/2019 17:49Passene-1954
4Issue301/01/2019 00:00Passfeb-1911
5Issue401/01/2019 19:36FAILmar-1922
6Issue515/01/2019 09:18Passabr-1911
7Issue631/01/2019 09:37Passmay-1910
8Issue731/01/2019 23:59Passjun-1910
9Issue815/02/2019 09:51Passdic-1922
10Issue915/03/2019 11:51Pass
11Issue1015/03/2019 11:59Pass
12Issue1115/04/2019 12:27Pass
13Issue1215/05/2019 09:08FAIL
14Issue1315/06/2019 09:13FAIL
15Issue1415/12/2018 09:31Pass
16Issue1515/12/2018 09:31Pass
Hoja1
Cell Formulas
RangeFormula
F2:F9F2=SUMPRODUCT(($B$2:$B$16>=$E2)*(INT($B$2:$B$16)<=INT(EOMONTH($E2,0))))
G2:G9G2=SUMPRODUCT(($B$2:$B$16>=$E2)*(INT($B$2:$B$16)<=INT(EOMONTH($E2,0)))*($C$2:$C$16="Pass"))
 
Upvote 0
Dear @DanteAmor,

Thank you, appreciated. I tried on sample data. Tomorrow I will try on actual data and let you know.
I guess SUMPRODUCT does not allow selection of complete column e.g fixing B colum =SUMPRODUCT(($B$:$B$>=$E2)*(INT($B$:$B$)<=INT(EOMONTH($E2,0))))

As when I tried fixing complete column it does not work.

Regards,
Waqas
Thank you very much. It work
 
Upvote 0
Apparently it doesn't work with the entire column.
Although sumproduct is captured as a regular formula, it is an array formula. Internally it makes the calculations as a data array.
Therefore it is not recommended to use this type of formulas with the entire column. It is always advisable to fix the data, if you have 2,000 records, for example, you can leave a slack up to 2,500.

If you need to use the entire column, there is the Tetra option.
 
Upvote 0
Dear @DanteAmor,

That's fine, I will fix the range.

First formula works: On my actual data, first formula works but second is not working for getting results.

Second formula does not properly works:
In my actual, I have 15000 rows but formula only works till 979 rows and strangely do not work after 979. If goes beyond 979 it shows #N/A.

I checked perhaps there is something wrong in 980 row but nothing odd there or there row in data.

=SUMPRODUCT(('Sheet2'!$AR$2:$AR$15000>=$D6)*(INT('Sheet2'!$AR$2:$AR$15000)<=INT(EOMONTH($D6;0)))*('Sheet2'!AL2:AL15000="YES"))

IssueReported DateResults
(it is calculated column as well)
Reported Date
(=Table13[@[Reported Date]])
ISSUE10001​
14/01/2019 17:49:57NOJan-19
ISSUE10001​
14/01/2019 18:08:26YESJan-19
ISSUE10001​
14/01/2019 18:41:36YESJan-19
ISSUE10001​
14/01/2019 19:36:39NOJan-19
ISSUE10001​
15/01/2019 9:18:06YESJan-19
ISSUE10001​
15/01/2019 9:37:55YESJan-19
ISSUE10001​
15/01/2019 9:53:06YESJan-19
ISSUE10001​
15/01/2019 9:51:50YESJan-19
ISSUE10001​
15/01/2019 11:51:52YESJan-19
ISSUE10001​
15/01/2019 11:59:55YESJan-19
ISSUE10001​
15/01/2019 12:27:17YESJan-19
ISSUE10001​
15/01/2019 9:08:04YESJan-19
ISSUE10001​
15/01/2019 9:13:19YESJan-19
ISSUE10001​
15/01/2019 9:28:02YESJan-19
ISSUE10001​
15/01/2019 9:31:44YESJan-19
 
Upvote 0
It works for me with 200,000 records.
I don't know if it's the excel version.
Did you try the Tetra formula?
 
Upvote 0
Hi DanteAmor,

Could be, that is why I am using now =COUNTIFS($D$2:$D$130000;C195;$I$2:$I$130000;"Yes").

Now I have another challenge.

I am calculating average of issues opened and when I tried to do averageifs function it does not work or says "You have enter too few arguments for this function".

Issue​
Date​
Results​
Reported Date​
Average Age​
A​
B​
C​
D​
E​
ISSUE10001
14/01/2019 17:49​
NO​
Jan-19​
-32​
ISSUE10001
14/01/2019 18:08​
YES​
Jan-19​
-32​
ISSUE10001
14/02/2019 18:41​
YES​
Feb-19​
43​
ISSUE10001
14/02/2019 19:36​
NO​
Feb-19​
-32​
ISSUE10001
15/02/2019 09:18​
YES​
Feb-19​
-32​
ISSUE10001
15/03/2019 09:37​
YES​
Mar-19​
-32​
ISSUE10001
15/03/2019 09:53​
YES​
Mar-19​
-32​
ISSUE10001
15/04/2019 09:51​
YES​
Apr-19​
-32​
ISSUE10001
15/04/2019 11:51​
YES​
Apr-19​
59​
ISSUE10001
15/05/2019 11:59​
YES​
May-19​
332​
ISSUE10001
15/05/2019 12:27​
YES​
May-19​
44​
ISSUE10001
15/05/2019 09:08​
YES​
May-19​
42​
ISSUE10001
15/06/2019 09:13​
YES​
Jun-19​
242​
ISSUE10001
15/06/2019 09:28​
YES​
Jun-19​
22​
ISSUE10001
15/06/2019 09:31​
YES​
Jun-19​
22​


Result required

Month​
Results​
Average Age​
A​
B​
E​
Jan-19​
1​
-32​
Feb-19​
2​
-7​
Mar-19​
2​
-32​
Apr-19​
2​
14​
May-19​
2​
139​
Jun-19​
3​
95​

1.JPG

Regards,
Waqas
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,182
Members
453,021
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top