Share via

Calculate a Count of Last 7 Days and Last 30 Days Using the Current Date

Anonymous
2019-11-04T15:43:54+00:00

I am trying to calculate the count of a string of data based upon the last 7 days and the last 30 days using the current date.

I do not want to manually update the date.

Column A = Dates

Column B = Data

I can make the count work by using the manual date:

=COUNTIFS(Data2!$A:$A,"<11/5/2019",Data2!$A:$A,">10/27/2019",Data2!$B:$B,"Hard Rock")

This brings back the correct counts.

But, If I use the TODAY() function (or the NOW() function), or direct the criteria to a cell that holds the TODAY() function, it does not work.

=COUNTIFS(Data2!$A:$A,"<=TODAY()+1",Data2!$A:$A,">=TODAY()-8",Data2!$B:$B,"Hard Rock")

=COUNTIFS(Data2!$A:$A,"<=E31",Data2!$A:$A,">=F31",Data2!$B:$B,"Hard Rock")

My theory is that the criteria section cannot hold formulas?

Can anyone help with my issue?

Thanks

~Kim

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Andreas Killer 144.1K Reputation points Volunteer Moderator
2019-11-04T16:06:35+00:00

=COUNTIFS(Data2!$A:$A,"<=TODAY()+1",Data2!$A:$A,">=TODAY()-8",Data2!$B:$B,"Hard Rock")

Your "TODAY()+1" is a string, but you need to call the function:

=COUNTIFS(Data2!$A:$A,"<="&TODAY()+1,Data2!$A:$A,">="&TODAY()-8,Data2!$B:$B,"Hard Rock")

Andreas.

Was this answer helpful?

6 people found this answer helpful.
0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Anonymous
    2019-11-04T16:26:50+00:00

    It works!

    It also helps me to see how the function works as well.

    Thank you so much for your help.

    ~Kim

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments