• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

How to use COUNTIF with date variable?

Eloise T

Active Member
Please refer to the attachment:
Column D contains the number of times a Title in Column A has appeared over the period of time referenced in Row 1 using the COUNTIF formula.
I would like Column E to contain a similar formula to show the number of times a Title in Column A has appeared as of =(TODAY) minus 365 days.

Column D formula: =COUNTIF(F2:AAA2,"X") where F2 is the date 09/01/2013 and
Column E formula needs to be similar to Column F but only COUNTIF for the last year from whatever TODAY happens to be.

=COUNTIF(((TODAY)-365):AAA2,"X") didn't work. :-(

Thank you in advance!
 

Attachments

  • Chandoo - Title repetitions.xlsm
    195.6 KB · Views: 8
Last edited:
You coulduse index function.
Something like...
Code:
=COUNTIF($F2:INDEX($F$1:$AAA2,ROWS($1:2),MATCH(TODAY(),$F$1:$AAA$1,1)),"x")
Copy down.

Edit: That was for Column D. From 9/1/13 to Today().
For E column. You can use...
Code:
=COUNTIF(INDEX($F$1:$AAA2,ROWS($1:2),MATCH(TODAY()-365,$F$1:$AAA$1,1)):INDEX($AAA$1:$AAA2,ROWS($1:2)),"x")
 
Last edited:
You coulduse index function.
Something like...
Code:
=COUNTIFS($F2:INDEX($F$1:$AAA2,ROWS($1:2),MATCH(TODAY(),$F$1:$AAA$1,1)),"x")
Copy down.

Edit: That was for Column D. From 9/1/13 to Today().
For E column. You can use...
Code:
=COUNTIF(INDEX($F$1:$AAA2,ROWS($1:2),MATCH(TODAY()-365,$F$1:$AAA$1,1)):INDEX($AAA$1:$AAA2,ROWS($1:2)),"x")
Column D currently works without modification.
Your formula if used as Column E, which is where it needs to work, does not. Am I missing something in the explanation?
Column D reports the quantity of Xs from 09/01/13...which it currently does.
Column E needs to report the quantity of Xs for only the last year.
 
Give me bit more explanation on how it isn't working.
Is it giving error values? Or something else?
The formula can simply be copied and pasted into E2.

See attached.
 

Attachments

  • Chandoo - Title repetitions.xlsm
    196.7 KB · Views: 7
IT WORKS, Thanks!

I had plugged in the wrong formula for Column E:
=COUNTIFS($F2:INDEX($F$1:$AAA2,ROWS($1:2),MATCH(TODAY(),$F$1:$AAA$1,1)),"X")

Instead of:
=COUNTIF(INDEX($F$1:$AAA2,ROWS($1:2),MATCH(TODAY()-365,$F$1:$AAA$1,1)):INDEX($AAA$1:$AAA2,ROWS($1:2)),"X")
 
Back
Top