How to use AVG and COLLECT to average data based on multiple criteria?
Goal: To average the estimated GP data in a column on a reference sheet based on the person assigned to the projects and the completion date being within a specific quarter. For example, I need to know the average estimated GP for all projects assigned to PersonXYZ, for March, April, and May.
I have the Average working for each criteria separately but when I try to combine them using the AVG(COLLECT)), it fails. Below are two formulas that work followed by the combined formula that does not work.
=AVERAGEIF({PM}, Abbreviation@row, {Estimated GP})
=AVERAGEIF({Completed Date}, OR(MONTH(@cell) = 3, MONTH(@cell) = 4, MONTH(@cell) = 5), {Estimated GP})
=AVG(COLLECT({Estimated GP}, {Completed Date}, OR(MONTH(@cell) = 3, MONTH(@cell) = 4, MONTH(@cell) = 5), {PM}, Abbreviation@row))
Error I receive is invalid data type.
All data from columns on single sheet.
Answers
-
Hi @StephenC
Your formula structure looks correct to me! An Invalid Data Type error can sometimes occur with the MONTH function if the range it's evaluating has blank cells or cells with text in them.
Try wrapping each MONTH function in an IFERROR Function to exclude those cells...like so:
IFERROR(MONTH(@cell), 0)
=AVG(COLLECT({Estimated GP}, {Completed Date}, OR(IFERROR(MONTH(@cell), 0) = 3, IFERROR(MONTH(@cell), 0)= 4, IFERROR(MONTH(@cell), 0) = 5), {PM}, Abbreviation@row))
Cheers,
Genevieve
Join us for Jumpstart 2025 with Community on 23 January (in two time zones)! 🎉 Register here.
Help Article Resources
Categories
- All Categories
- 14 Welcome to the Community
- Customer Resources
- 65.4K Get Help
- 447 Global Discussions
- 144 Industry Talk
- 479 Announcements
- 5.1K Ideas & Feature Requests
- 85 Brandfolder
- 151 Just for fun
- 72 Community Job Board
- 490 Show & Tell
- 33 Member Spotlight
- 2 SmartStories
- 302 Events
- 36 Webinars
- 7.3K Forum Archives
Check out the Formula Handbook template!