COUNTIF formula to count how many projects the past 2 years? The date is listed as 02/03/19
and I would like to go back the past 2 years.
Best Answers
-
Ok. You are going to either want to convert it to a date type column with date type data, or we will need to use a date type helper column with a formula to convert it. The first option is most likely going to be the least complicated.
Once we have date type values, we can use
=COUNTIFS([Date Column]:[Date Column], AND(@cell >= DATE(YEAR(TODAY()) - 2, MONTH(TODAY()), DAY(TODAY())), @cell <= TODAY()))
-
To pull unique IDs, you are going to want something more like this...
=COUNT(DISTINCT(COLLECT([ID( Column]:[ID Column], [Date Column]:[Date Column], AND(@cell >= DATE(YEAR(TODAY()) - 2, MONTH(TODAY()), DAY(TODAY())), @cell <= TODAY()))))
-
Try some "@cell" references in the OR function.
=COUNT(DISTINCT(COLLECT({Proj. No.}, {Sheet}, OR(@cell = "Renewals / Extensions", @cell = "Renewals/Extensions"), {Lease Exp. Date}, AND(@cell >= DATE(YEAR(TODAY()) - 2, MONTH(TODAY()), DAY(TODAY())), @cell <= TODAY()))))
-
Answers
-
Are the dates in a date type column and entered as date type data (as opposed to a text string that just looks like a date)?
Are you wanting a rolling two years from TODAY, or are you wanting to specify a year or years?
-
@Paul Newcome The column property is a text/number.. hopefully, that answers your question. And yes it'd be great to count from TODAY the past 2 years. Thank you!
-
Ok. You are going to either want to convert it to a date type column with date type data, or we will need to use a date type helper column with a formula to convert it. The first option is most likely going to be the least complicated.
Once we have date type values, we can use
=COUNTIFS([Date Column]:[Date Column], AND(@cell >= DATE(YEAR(TODAY()) - 2, MONTH(TODAY()), DAY(TODAY())), @cell <= TODAY()))
-
Thank you so much @Paul Newcome! Also, how do I add on to that formula so that it counts each unique number IDs?
-
To pull unique IDs, you are going to want something more like this...
=COUNT(DISTINCT(COLLECT([ID( Column]:[ID Column], [Date Column]:[Date Column], AND(@cell >= DATE(YEAR(TODAY()) - 2, MONTH(TODAY()), DAY(TODAY())), @cell <= TODAY()))))
-
Thank you so much @Paul Newcome!!
-
Sorry, I have a follow up question
=COUNT(DISTINCT(COLLECT({Proj. No.}, {Sheet}, OR("Renewals / Extensions", "Renewals/Extensions"), {Lease Exp. Date}, AND(@cell >= DATE(YEAR(TODAY()) - 2, MONTH(TODAY()), DAY(TODAY())), @cell <= TODAY()))))
I want to count all the rows that have "Renewals / Extensions" or "Renewals/Extensions" on the Sheet column but it's only coming up as 1. Do you have any recommendations so that it counts all the rows?
-
Try some "@cell" references in the OR function.
=COUNT(DISTINCT(COLLECT({Proj. No.}, {Sheet}, OR(@cell = "Renewals / Extensions", @cell = "Renewals/Extensions"), {Lease Exp. Date}, AND(@cell >= DATE(YEAR(TODAY()) - 2, MONTH(TODAY()), DAY(TODAY())), @cell <= TODAY()))))
-
Thank you @Paul Newcome!!
-
Help Article Resources
Categories
- All Categories
- 14 Welcome to the Community
- Customer Resources
- 67.1K Get Help
- 448 Global Discussions
- 154 Industry Talk
- 503 Announcements
- 5.4K Ideas & Feature Requests
- 85 Brandfolder
- 156 Just for fun
- 80 Community Job Board
- 512 Show & Tell
- 34 Member Spotlight
- 2 SmartStories
- 308 Events
- 36 Webinars
- 7.3K Forum Archives
Check out the Formula Handbook template!