If statement logic

Hello Community,

I’m new to this, new to regex and conditional logic - having trouble figuring this out:

I have a simple table listing projects. Each row is a project, and the columns for Project Size (Large, Medium, Small) and then a project duration column that I want to automatically add Days to based on the selection of Project Size.

If Project Size = Large then set Project Duration to 56 days in that row. Also If Project Size = Medium then set Project Duration to 36 days in that row… etc.

Can anyone help?

Thank you

Hi there @Jason_Luna :blush: and Welcome to the Community :tada: !

Is this what you were looking for :blush: ?

I used a SwitchIf() formula instead of If() :blush:

SwitchIf(thisRow.Size="Large",56,thisRow.Size="Medium",36,thisRow.Size="Small",16)

SwitchIf() tend to be more appropriated in those cases as you don’t need to precise the otherwise part of the formula.

Here, with in my SwitchIf() formula in the Duration field, it just says that :

  • if the Size mentioned in this row is equal at “Large”, then put 56 here
  • if the Size mentioned in this row is equal at “Medium”, then put 36 here
  • if the Size mentioned in this row is equal at “Small”, then put 16 here

Note that because the Duration field is a formatted as a Duration type of field (where I set the Precision to Days, I didn’t need to precise what the 56, 36 and 16 were, they were automatically put as days :blush: .

With an If() you would probably need to nest them and have a formula looking like this :

If(
    thisRow.Size="Large",56,
        If(thisRow.Size="Medium",36,
            If(thisRow.Size="Small",16,"")
))

Which says this time :

if the Size mentioned in this row is equal at “Large”, then put 56 here, otherwise, if the Size mentioned in this row is equal at “Medium”, then put 36 here, otherwise, if the Size mentioned in this row is equal at “Small”, then put 16 here, otherwise, Blank.

:blush:

2 Likes

Wow! Thank you! I think my logic fell apart because I was trying to incorrectly nest the if statements. But switchif looks like a better way to go and does exactly what I need it to do! Thank you so much!

You’re welcome :blush: !

1 Like