AVG(COLLECT) formula - need help please

This is what I have working but it's not what I want because it only works for an exact match for date.

=AVG(COLLECT([Column5]1:[Column5]4, [Column7]1:[Column7]4, DATE(2022, 10, 4)))

Column 7 is a DATE column and I want to average the numbers in Column 5 only if the date range is between Oct 1 to Oct 31.

It works for a single date but I don't know why I can't put in a date range. I have tried all kinds of things but nothing works.


Thanks!

Answers

  • Andrée Starå
    Andrée Starå ✭✭✭✭✭✭
    edited 10/14/22

    Hi @AB200001

    I hope you're well and safe!

    Try something like this.

    =IFERROR(AVG(COLLECT([Column5]1:[Column5]4, [Column7]1:[Column7]4, AND(@cell >= DATE(2022, 10, 1), @cell <= DATE(2022, 10, 31)))), "")

    Did that work/help?

    I hope that helps!

    Be safe, and have a fantastic weekend!

    Best,

    Andrée Starå | Workflow Consultant / CEO @ WORK BOLD

    Did my post(s) help or answer your question or solve your problem? Please support the Community by marking it Insightful/Vote Up, Awesome, or/and as the accepted answer. It will make it easier for others to find a solution or help to answer!

    SMARTSHEET EXPERT CONSULTANT & PARTNER

    Andrée Starå | Workflow Consultant / CEO @ WORK BOLD

    W: www.workbold.com | E:andree@workbold.com | P: +46 (0) - 72 - 510 99 35

    Feel free to contact me for help with Smartsheet, integrations, general workflow advice, or anything else.

  • I got "unparseable" using that - I have tried the AVG(COLLECT) dozens of times with zero success so I switched to "AVERAGEIF" and that seems to work.

    Here's my formula based on your suggestion. I wish I could figure out why it doesn't work. The 2 fields are "Date" and "number/text".

    =IFERROR(AVG(COLLECT([Total Score no formula]1:[Total Score no formula]10), [Date Scored]1:[Date Scored]10, AND(@cell >= DATE(2022, 10, 1), @cell <= DATE(2022, 10, 31)))), "")

  • Genevieve P.
    Genevieve P. Employee Admin

    Hi @AB200001

    It looks like you're closing off the COLLECT function too early. Think of COLLECT like a filter... where you first list the column or range that you're filtering, then list each column and criteria after it.

    I've removed out the parentheses in the middle, bolded portion:

    =IFERROR(AVG(COLLECT([Total Score no formula]1:[Total Score no formula]10, [Date Scored]1:[Date Scored]10, AND(@cell >= DATE(2022, 10, 1), @cell <= DATE(2022, 10, 31)))), "")


    I will also note that you're limiting your range to 10 rows in this function, is that what you wanted to do? If you want to search the entire column, remove out the row numbers after the column names:

    =IFERROR(AVG(COLLECT([Total Score no formula]:[Total Score no formula], [Date Scored]:[Date Scored], AND(@cell >= DATE(2022, 10, 1), @cell <= DATE(2022, 10, 31)))), "")

    Cheers,

    Genevieve

  • That makes sense but I'm still getting unparsable. I have no idea why. Thanks for trying though!

  • Genevieve P.
    Genevieve P. Employee Admin

    Hi @AB200001

    Can you post a screen capture of your formula open in the cell, showing the column names in your sheet?

    It sounds like perhaps there's either a misplaced parentheses or a column name was input incorrectly.

    Thanks!

Help Article Resources

Want to practice working with formulas directly in Smartsheet?

Check out the Formula Handbook template!