Formula IF, nest AND in OR
Hello there,
I have two columns of data with days employees work with drop down selection (M, Tu, W, Th, F, S, Su) and a cell linked date $TODAY$1. I want to return today's date if it is on the day of the week the employee is schedule to work. The formula below have no errors, but it is not returning the values on test dates:
=IF(OR([Days of Week]@row = "Su", WEEKDAY($TODAY$1) = 1), $TODAY$1, IF(AND([Days of Week]@row = "M", WEEKDAY($TODAY$1) = 2), $TODAY$1, IF(AND([Days of Week]@row = "Tu", WEEKDAY($TODAY$1) = 3), $TODAY$1, IF(AND([Days of Week]@row = "W", WEEKDAY($TODAY$1) = 4), $TODAY$1, IF(AND([Days of Week]@row = "Th", WEEKDAY($TODAY$1) = 5), $TODAY$1, IF(AND([Days of Week]@row = "F", WEEKDAY($TODAY$1) = 6), $TODAY$1, IF(AND([Days of Week]@row = "S", WEEKDAY($TODAY$1) = 7), $TODAY$1)))))))
Please help.
Thank you!
Best Answers
-
This seems to have worked. Hopefully, I covered all logistical conditions. Fingers crossed.
=IF(AND(HAS([Days of Week]@row, "Su"), WEEKDAY($TODAY$1) = 1), $TODAY$1, IF(AND(HAS([Days of Week]@row, "M"), WEEKDAY($TODAY$1) = 2), $TODAY$1, IF(AND(HAS([Days of Week]@row, "Tu"), WEEKDAY($TODAY$1) = 3), $TODAY$1, IF(AND(HAS([Days of Week]@row, "W"), WEEKDAY($TODAY$1) = 4), $TODAY$1, IF(AND(HAS([Days of Week]@row, "Th"), WEEKDAY($TODAY$1) = 5), $TODAY$1, IF(AND(HAS([Days of Week]@row, "F"), WEEKDAY($TODAY$1) = 6), $TODAY$1, IF(AND(HAS([Days of Week]@row, "S"), WEEKDAY($TODAY$1) = 7), $TODAY$1, 0)))))))
-
Hi Tracy,
Looks good! I'm glad you sorted out the HAS function, which is meant exactly for this type of situation (looking into a mutli-select column).
Thanks for sharing your solution!
Answers
-
Below is a screenshot of my columns. I think I need to use CONTAINS function as well, but have not had success.
-
This seems to have worked. Hopefully, I covered all logistical conditions. Fingers crossed.
=IF(AND(HAS([Days of Week]@row, "Su"), WEEKDAY($TODAY$1) = 1), $TODAY$1, IF(AND(HAS([Days of Week]@row, "M"), WEEKDAY($TODAY$1) = 2), $TODAY$1, IF(AND(HAS([Days of Week]@row, "Tu"), WEEKDAY($TODAY$1) = 3), $TODAY$1, IF(AND(HAS([Days of Week]@row, "W"), WEEKDAY($TODAY$1) = 4), $TODAY$1, IF(AND(HAS([Days of Week]@row, "Th"), WEEKDAY($TODAY$1) = 5), $TODAY$1, IF(AND(HAS([Days of Week]@row, "F"), WEEKDAY($TODAY$1) = 6), $TODAY$1, IF(AND(HAS([Days of Week]@row, "S"), WEEKDAY($TODAY$1) = 7), $TODAY$1, 0)))))))
-
Hi Tracy,
Looks good! I'm glad you sorted out the HAS function, which is meant exactly for this type of situation (looking into a mutli-select column).
Thanks for sharing your solution!
Help Article Resources
Categories
- All Categories
- 14 Welcome to the Community
- Smartsheet Customer Resources
- 63K Get Help
- 380 Global Discussions
- 212 Industry Talk
- 442 Announcements
- 4.6K Ideas & Feature Requests
- 140 Brandfolder
- 129 Just for fun
- 130 Community Job Board
- 449 Show & Tell
- 30 Member Spotlight
- 1 SmartStories
- 305 Events
- 34 Webinars
- 7.3K Forum Archives
Check out the Formula Handbook template!