# Re: Formula connected to Single Select Field

857 0
cancel
Showing results for
Did you mean:
5 - Automation Enthusiast

Hi Everyone,

I’m trying to write a formula to calculate the length of service for our volunteers based on a single select field with options Active/Inactive. I’ve gotten the formula to return a result for Active volunteers, but for the Inactive volunteers it remains empty.
Here’s the formula, how do I get a result for the Inactive volunteers?

IF({Active/Inactive}=“Active”,DATETIME_DIFF(TODAY(),{Start Date},‘days’,IF({Active/Inactive}=“Inactive”,DATETIME_DIFF({End Date},{Start Date},‘days’))))

2 Replies 2
6 - Interface Innovator

Looks like you may have a parentheses in the wrong spot, try this:

IF({Active/Inactive}=“Active”, DATETIME_DIFF(TODAY(),{Start Date},‘days’), IF({Active/Inactive}=“Inactive”,DATETIME_DIFF({End Date},{Start Date},‘days’)))

18 - Pluto

As an alternate solution, the formula can be simplified a bit using SWITCH, if only by making the parenthesis-placement issue a little easier because you’re not nesting so much:

``````SWITCH({Active/Inactive}, "Active", DATETIME_DIFF(TODAY(),{Start Date},'days'),
"Inactive", DATETIME_DIFF({End Date},{Start Date},‘days’))``````