# Help with formula for Current, Next, Last week calc based on date

✭✭
edited 12/12/23

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

Tags:

• ✭✭

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")))))))

• ✭✭✭✭✭✭

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

Want to practice working with formulas directly in Smartsheet?

Check out the Formula Handbook template!