How do I check for duplicates within several columns and check a box
Hi All,
I'm making a grid for staffing events. Basically each event can have up to 3 staff members. I want a formula that will check for if there are multiple events on the same date and if a staff member is accidentally double booked. If they are double booked, to check the checkbox so I can run some conditional formatting. I've attached an example spreadsheet below.
What would my formula look like to check the "Double Booked" box?
Thanks!
Brett
Best Answer
-
This one is ugly, but can work. You need to COUNTIFS based on three individual columns (using IF(COUNTIFS(Date:Date, Date@row, [Staff Name]:[Staff Name], [Staff Name]@row) as your base forumla), so you need to compare 3 names to 3 columns individually, hence the (9) COUNTIFS below. Then you wrap that all in a IF > 3 because it will always count the name in the current row. Because if there's more than three, that means it's matching in another row.
=IF(COUNTIFS(Date:Date, Date@row, [Staff Name]:[Staff Name], [Staff Name]@row) + COUNTIFS(Date:Date, Date@row, [Second Staff Name]:[Second Staff Name], [Staff Name]@row) + COUNTIFS(Date:Date, Date@row, [Third Staff Name]:[Third Staff Name], [Staff Name]@row) + COUNTIFS(Date:Date, Date@row, [Staff Name]:[Staff Name], [Second Staff Name]@row) + COUNTIFS(Date:Date, Date@row, [Second Staff Name]:[Second Staff Name], [Second Staff Name]@row) + COUNTIFS(Date:Date, Date@row, [Third Staff Name]:[Third Staff Name], [Second Staff Name]@row) + COUNTIFS(Date:Date, Date@row, [Staff Name]:[Staff Name], [Third Staff Name]@row) + COUNTIFS(Date:Date, Date@row, [Second Staff Name]:[Second Staff Name], [Third Staff Name]@row) + COUNTIFS(Date:Date, Date@row, [Third Staff Name]:[Third Staff Name], [Third Staff Name]@row) > 3, 1, 0)
Jason Tarpinian - Sevan Technology
Smartsheet Aligned Partner
Answers
-
This one is ugly, but can work. You need to COUNTIFS based on three individual columns (using IF(COUNTIFS(Date:Date, Date@row, [Staff Name]:[Staff Name], [Staff Name]@row) as your base forumla), so you need to compare 3 names to 3 columns individually, hence the (9) COUNTIFS below. Then you wrap that all in a IF > 3 because it will always count the name in the current row. Because if there's more than three, that means it's matching in another row.
=IF(COUNTIFS(Date:Date, Date@row, [Staff Name]:[Staff Name], [Staff Name]@row) + COUNTIFS(Date:Date, Date@row, [Second Staff Name]:[Second Staff Name], [Staff Name]@row) + COUNTIFS(Date:Date, Date@row, [Third Staff Name]:[Third Staff Name], [Staff Name]@row) + COUNTIFS(Date:Date, Date@row, [Staff Name]:[Staff Name], [Second Staff Name]@row) + COUNTIFS(Date:Date, Date@row, [Second Staff Name]:[Second Staff Name], [Second Staff Name]@row) + COUNTIFS(Date:Date, Date@row, [Third Staff Name]:[Third Staff Name], [Second Staff Name]@row) + COUNTIFS(Date:Date, Date@row, [Staff Name]:[Staff Name], [Third Staff Name]@row) + COUNTIFS(Date:Date, Date@row, [Second Staff Name]:[Second Staff Name], [Third Staff Name]@row) + COUNTIFS(Date:Date, Date@row, [Third Staff Name]:[Third Staff Name], [Third Staff Name]@row) > 3, 1, 0)
Jason Tarpinian - Sevan Technology
Smartsheet Aligned Partner
-
Thanks so much Jason, this clears up some things I did have to change the greater than 3 to 4 to make this work but it did!
-
Jason now I got most of it to work, but how can I get that formula to ignore blank staffing cells in each column?
Categories
- All Categories
- 14 Welcome to the Community
- Customer Resources
- 64.9K Get Help
- 441 Global Discussions
- 140 Industry Talk
- 472 Announcements
- 4.9K Ideas & Feature Requests
- 129 Brandfolder
- 148 Just for fun
- 68 Community Job Board
- 497 Show & Tell
- 33 Member Spotlight
- 2 SmartStories
- 300 Events
- 36 Webinars
- 7.3K Forum Archives