Countif after certain date

JAA
JAA
edited 12/09/19 in Formulas and Functions

Hi!

I'm trying to create a formula that will count the number of rows that have a "Delivery Date" after 1/1/2019. Any row with a date prior to that should not be counted. I also do not want blank rows counted.

In the screen capture attached, you'll see all but one populated row should be counted.

Any suggestions on a formula I could use? I appreciate any assistance you can provide!

Josh

2019-03-29_11-30-11.jpg

Tags:

Comments

  • Jason Tarpinian
    Jason Tarpinian ✭✭✭✭✭✭
    edited 03/29/19

    I don't know how to input hard dates within SmartSheet formulas, so I have a solution by adding a new column. Call it whatever (I used "Anchor Date" to test it out), and copy/paste your 1/1/19 date into the entire row) then use:

    =COUNTIFS([Delivery Date]$1:[Delivery Date]$7, [Delivery Date]1 <> "", [Delivery Date]$1:[Delivery Date]$7, [Delivery Date]1 > [Anchor Date]1)

    You can drop this formula through the whole column if you'd like. And every row would show the total. If you didn't want the blank rows to show any number edit the formula to exclude blanks:

    =IF([Delivery Date]1 = "", "", COUNTIFS([Delivery Date]$1:[Delivery Date]$7, [Delivery Date]1 <> "", [Delivery Date]$1:[Delivery Date]$7, [Delivery Date]1 > [Anchor Date]1))

    Jason Tarpinian - Sevan Technology

    Smartsheet Aligned Partner

  • L_123
    L_123 ✭✭✭✭✭✭

    to input a hard date you use the Date Reference

     

    =Date(2019,12,31)

    will return december 31, 2019

    This can be used inside of formulas as well

  • JAA
    JAA
    edited 03/29/19

    Great! I accomplished what I needed with the below formula.

    =COUNTIFS([Delivery Date]:[Delivery Date], [Delivery Date]1 <> "", [Delivery Date]:[Delivery Date], [Delivery Date]1 > DATE(2019, 1, 1))

    2019-03-29_12-33-19.jpg

  • Thank you! This in addition to the above comment got me closer to where I'd like to be.

  • Jason Tarpinian
    Jason Tarpinian ✭✭✭✭✭✭

    I will have to remember that one, it's not often I need to use it, but for those couple of times!

    Jason Tarpinian - Sevan Technology

    Smartsheet Aligned Partner

  • If I wanted to add in that the date would also have to be before today's date (so Jan 1st through today), what would you suggest?

  • L_123
    L_123 ✭✭✭✭✭✭

    if you want it to always be the current year and not have to update the formula annually you can use this

     

    date(year(today()),1,1)

  • Found what I needed:

     

    =COUNTIFS([Delivery Date]:[Delivery Date], [Delivery Date]1 <> "", [Delivery Date]:[Delivery Date], [Delivery Date]1 > DATE(2019, 1, 1), [Delivery Date]:[Delivery Date], [Delivery Date]1 < TODAY())

  • Paul Newcome
    Paul Newcome ✭✭✭✭✭✭
    edited 04/01/19

    You can also use the AND function for your criteria along with @cell references.

     

    =COUNTIFS([Delivery Date]:[Delivery Date], AND(ISDATE(@cell), YEAR(@cell = YEAR(TODAY()), @cell < TODAY()))

     

    You are only referencing one range. Your date range. You can use the AND function to combine all of the criteria to keep from having to repeat the range.

     

    In this particular formula we are saying to look at the [Delivery Date] column and count all cells that meet the following criteria:

    Is a date

    AND

    Has the current year

    AND

    is before today.

    .

    Here is a page that describes the various functions used in Smartsheet formulas.

    https://help.smartsheet.com/functions

     

    Here is a page that helps with troubleshooting errors with formulas and functions.

    https://help.smartsheet.com/articles/2476176-formula-error-messages?_ga=2.163823034.487922610.1554120052-1302373248.1552411124

     

    And if you look through the templates, there is one called "Smartsheet Formula Examples". This is an actual Smartsheet with all of the functions explained and shown in use along with a few hints and tips. Because it is a sheet, it is interactive. You can play around with the formulas to see what happens. If you mess something up, you can either use the Undo button or simply delete the sheet and re-download the template.

  • Great info! I love the tip about the available template. 

Help Article Resources

Want to practice working with formulas directly in Smartsheet?

Check out the Formula Handbook template!