Combine results of multiple COLLECTs? Or alternate strategy?
I am trying to get a count of trainees in my app, each trainee has a unique "Member ID". A trainee is defined as meeting one or more of the following criteria:
- has a value of "Submitted" or "Issued" in the "Status" column of the "Reimbursements - Approved" sheet
- has the current grant year (e.g., "GYr 4") in the "Mentee" column of the "Member Roster" sheet
- has the current grant year (e.g., "GYr 4") in the "Resident" column of the "Member Roster" sheet
I have the following 3 COUNT/DISTINCT/COLLECT statements which all work fine individually, but I need to find the count of distinct MEMBER IDs from the results of all 3 COLLECTs combined:
=COUNT(DISTINCT(COLLECT({REIMB APPROVED | Member ID}, {REIMB APPROVED | Status}, OR(@cell = "Submitted", @cell = "Issued"))))
=COUNT(DISTINCT(COLLECT({MEMBER ROSTER | Member ID}, {MEMBER ROSTER | Mentee}, [Current Grant Year]@row)))
=COUNT(DISTINCT(COLLECT({MEMBER ROSTER | Member ID}, {MEMBER ROSTER | Resident}, [Current Grant Year]@row)))
In SQL, I could use UNIONs to combine the results of all 3 COLLECTS, then select the distinct Member IDs from those combined results. Is something like this possible in Smartsheet?
Answers
-
I would try the below
=Sum(COUNT(DISTINCT(COLLECT({REIMB APPROVED | Member ID}, {REIMB APPROVED | Status}, OR(@cell = "Submitted", @cell = "Issued")))),COUNT(DISTINCT(COLLECT({MEMBER ROSTER | Member ID}, {MEMBER ROSTER | Mentee}, [Current Grant Year]@row))),COUNT(DISTINCT(COLLECT({MEMBER ROSTER | Member ID}, {MEMBER ROSTER | Resident}, [Current Grant Year]@row))))
-
Thanks for the suggestion Hollie. A member can fall into more than one category at the same time so unfortunately I think this wouldn't eliminate duplicate occurrences of Member IDs. Ex: a member might have a reimbursement status of "Submitted" but also be a Mentee.
I'm hoping to accomplish something like this:
Get all Member IDs where reimbursement is Submitted or Issued (from Reimb-Approved sheet)
plus
Get all Member IDs where member is Mentee (from Member Roster sheet)
plus
Get all Member IDs where member is a Resident (from Member Roster sheet)So now I will have a pool of all Member IDs although some will be duplicated. Now remove all duplicate Member IDs from that pool, then get a count of unique remaining Member IDs.
-
Sounds like a helper column on your source sheet should help you out. Whenever I have a problem where I don't want to double count a record, build a helper column with your COLLECT criteria. In your situation, something like a checkbox column that you could simply then count.
=IF(AND(OR([REIMB Approved | Member ID]@row = "Submitted", [REIMB Approved | Member ID]@row = "Issued"), [MEMBER ROSTER | Mentee]@row = [Current Grant Year]@row, [MEMBER ROSTER | Resident]@row = [Current Grant Year]@row), true)
Depending on your setup, you may have to pull in the "Current Grant Year" from your other sheet, if that's calculated somehow special. And also sounds like you're trying to COLLECT 2 different ranges though (maybe it's too late on a Friday for me to understand why multiple ranges) so I'm not sure how that plays into not counting duplicates? Hopefully this helps to at least gets you close, the gist is that you do the easy formula on your source sheet and count from that.
Jason Tarpinian - Sevan Technology
Smartsheet Aligned Partner
Help Article Resources
Categories
- All Categories
- 14 Welcome to the Community
- Smartsheet Customer Resources
- 63.6K Get Help
- 403 Global Discussions
- 215 Industry Talk
- 455 Announcements
- 4.7K Ideas & Feature Requests
- 141 Brandfolder
- 136 Just for fun
- 56 Community Job Board
- 459 Show & Tell
- 31 Member Spotlight
- 1 SmartStories
- 296 Events
- 36 Webinars
- 7.3K Forum Archives
Check out the Formula Handbook template!