Help with formula for Current, Next, Last week calc based on date
I admit.. I'm gonna be lazy on this one. lol. I'm brand new to smart sheet.
We have a field called [Due Date] that is a date type field. I want to create a string field that follows this logic:
IF [Due Date] occurs during this week THEN "This Week"
ELSEIF [Due Date] occurs next week THEN "Next Week"
ELSEIF [Due Date] occurs last week THEN "Last Week"
ELSEIF [Due Date] occurs after next week THEN "After Next Week "
ELSEIF [Due Date] occurs before last week then "Before Last Week"
ELSE null()
I'm used to using Alteryx where I can write this exactly like I wrote it, but I'm having trouble achieving this using the nested if syntax of Smartsheet.
Thanks for any help!,
Craig
Best Answer
-
I figured it out
=IF( Status@row = "Complete", "Complete",
IF( ISBLANK([Due Date]@row), "No Due Date",
IF( WEEKNUMBER([Due Date]@row) = WEEKNUMBER(TODAY()), "This Week",
IF( WEEKNUMBER([Due Date]@row) = WEEKNUMBER(TODAY()) + 1, "Next Week",
IF( WEEKNUMBER([Due Date]@row) = WEEKNUMBER(TODAY()) - 1, "Last Week",
IF( WEEKNUMBER([Due Date]@row) > WEEKNUMBER(TODAY()) + 1, "After Next Week",
IF( WEEKNUMBER([Due Date]@row) < WEEKNUMBER(TODAY()) - 1, "Before Last Week")))))))
Answers
-
The syntax for the nested IF would be
=IF( [Due Date] occurs during this week , "This Week",
IF( [Due Date] occurs next week , "Next Week",
IF( [Due Date] occurs last week , "Last Week",
IF( [Due Date] occurs after next week , "After Next Week ",
IF( [Due Date] occurs before last week , "Before Last Week")))))
Each elseif is a new IF(
There is a comma to separate the logic and the result if true
Then another comma to separate the result if true and the result if false (which in your case is another IF)
You need to replace the part in bold with your logic to determine what constitutes "this week", etc.
-
The "occurs during" logic is really the part I needed help with. I would have eventually figured out the nested if part as I have done nested IFs in excel
-
I figured it out
=IF( Status@row = "Complete", "Complete",
IF( ISBLANK([Due Date]@row), "No Due Date",
IF( WEEKNUMBER([Due Date]@row) = WEEKNUMBER(TODAY()), "This Week",
IF( WEEKNUMBER([Due Date]@row) = WEEKNUMBER(TODAY()) + 1, "Next Week",
IF( WEEKNUMBER([Due Date]@row) = WEEKNUMBER(TODAY()) - 1, "Last Week",
IF( WEEKNUMBER([Due Date]@row) > WEEKNUMBER(TODAY()) + 1, "After Next Week",
IF( WEEKNUMBER([Due Date]@row) < WEEKNUMBER(TODAY()) - 1, "Before Last Week")))))))
Help Article Resources
Categories
- All Categories
- 14 Welcome to the Community
- Customer Resources
- 65.1K Get Help
- 444 Global Discussions
- 142 Industry Talk
- 472 Announcements
- 5K Ideas & Feature Requests
- 83 Brandfolder
- 150 Just for fun
- 71 Community Job Board
- 489 Show & Tell
- 33 Member Spotlight
- 2 SmartStories
- 301 Events
- 36 Webinars
- 7.3K Forum Archives
Check out the Formula Handbook template!