=COUNTIF returning zero value - perhaps date format error??

redspanna

Well-known Member
Joined
Jul 27, 2005
Messages
1,604
Office Version
  1. 365
Platform
  1. Windows
Hi all

I have a simple Data table and I'd like a formula to check down column F (Sales) for any value greater than Zero if the date in column H (Column2) matches the date held in cell ref J2

I have tried
=COUNTIFS(Data_Table[[#Headers],[SALES]], ">0", Data_Table[[#Headers],[Column2]], "="&J2)
but the retuen value is 0 in cell I2, where I would expect it to be 6 given the example data here..


Cell Formulas
RangeFormula
J1J1=COUNTIFS(Data_Table[[#Headers],[SALES]], ">0", Data_Table[[#Headers],[Column2]], ">"&J3)
B2:B10B2=IF(ISBLANK(A2),"",TEXT([@DATE],"mmm"))
C2:C10C2=IF(ISBLANK(A2),"",YEAR(EOMONTH(A2,9))-1&"-"&RIGHT(YEAR(EOMONTH(A2,9)),2))
D2:D10D2=IF(ISBLANK(A2),"",YEAR(A2))
E2:E10E2=IF(ISBLANK(A2),"",VLOOKUP(B2,Workings!$A$4:$C$15,3,FALSE))
G2:G10G2=IF(ISBLANK(A2),"",TEXT(A2,"DDD"))
H2:H10H2=IF(ISBLANK(A2),"",A2)
I2I2=COUNTIFS(Data_Table[[#Headers],[SALES]], ">0", Data_Table[[#Headers],[Column2]], ">"&J2)


I'm guessing its something to do perhaps with the way that column H and J2 is formatted to give the value as mmmm yyyy but can't figure it out

Appreciate any help
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
You're looking at the header row. Try:

Excel Formula:
=COUNTIFS(Data_Table[SALES], ">0", Data_Table[Column2], ">"&J2)
 
Upvote 0
Thanks @RoryA for your help
However I'm still not getting the correct/expected results

As you can see the updated formula in I2 is giving the result as 9 where as I'd expect it to be 7 as this is the number of times a value of more than ZERO and the month is the same as that in J2 is matched. The formula seems to be counting the data in rows 12 & 13 even though the dates are not January 2020

NDA.v14.xlsm
ABCDEFGHIJ
1DATEMONTHYEARYEAR2QSALESDAYColumn2Column3Column4
201-Jan-20January 20209January 2020
302-Jan-20140January 2020
403-Jan-20January 2020
504-Jan-2070January 2020
605-Jan-2070January 2020
706-Jan-20960January 2020
807-Jan-202000January 2020
908-Jan-20January 2020
1009-Jan-2070January 2020
1110-Jan-20475January 2020
1203-Mar-2250March 2022
1305-Sep-2225September 2022
Data (2)
Cell Formulas
RangeFormula
I2I2=COUNTIFS([SALES], ">0", [Column2], ">"&$H$2)
H2:H13H2=IF(ISBLANK(A2),"",A2)


Thanks again though for your help
 
Upvote 0
You used > rather than = for the month criterion
 
Upvote 0
You used > rather than = for the month criterion

OK, then thats changed I get a ZERO retun

NDA.v14.xlsm
ABCDEFGHIJ
1DATEMONTHYEARYEAR2QSALESDAYColumn2Column3Column4
201-Jan-20January 20200January 2020
302-Jan-20140January 2020
403-Jan-20January 2020
504-Jan-2070January 2020
605-Jan-2070January 2020
706-Jan-20960January 2020
807-Jan-202000January 2020
908-Jan-20January 2020
1009-Jan-2070January 2020
1110-Jan-20475January 2020
1203-Mar-2250March 2022
1305-Sep-2225September 2022
Data (2)
Cell Formulas
RangeFormula
I2I2=COUNTIFS([SALES], ">0", [Column2], "="&$J$2)
H2:H13H2=IF(ISBLANK(A2),"",A2)
 
Upvote 0
I suspect the value in J2 is 1st Jan which only matches one of the rows of data, and that one has no sales. If you want the entire month, you'll need to amend Column2 and J2 to use the same text representation of the month, or convert all dates to 1st of the respective month.
 
Upvote 0
Solution
I suspect the value in J2 is 1st Jan which only matches one of the rows of data, and that one has no sales. If you want the entire month, you'll need to amend Column2 and J2 to use the same text representation of the month, or convert all dates to 1st of the respective month.

Yehh, as I suspected, it was a formating issue....
I've changed the format to match on several cells and its now working as expected (I think ;))

Many thanks for your help
 
Upvote 0

Forum statistics

Threads
1,224,825
Messages
6,181,189
Members
453,020
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