Multiple if statements in one expression?

I am trying to put together an expression that looks at several different possible values:

What i want:
If Speed > 70 then = Speed - 30
If Speed is lower than 70 but higher than 30 then = Speed -15
If Speed lower than 30 then = Speed

I put this as my expression which i know is wrong but i cannot figure it out:

IF([Speed] > 70, [Speed] - 30, [Speed]), AND IF([Speed] < 70, [Speed] - 15, [Speed])

You need to do a nested IF:

IF(
   [Speed] > 70 , [Speed] - 30,
   IF(
      [Speed] < 30 , [Speed] , 
      [Speed] - 15
      )
)

There is a SWITCH() function for simplifying nested IF functions. Unfortunately I don’t think it can check for equivalencies such as greater or less thans yet, so the above nested IF() is the best solution.

@Steve is this correct?

3 Likes

That worked!

Thanks

If it works, it’s correct! :slight_smile:

You could also use IFS():

IFS(
 ([Speed] > 70),
   ([Speed] - 30),
 ([Speed] > 30),
   ([Speed] - 15),
 TRUE,
   [Speed]
)
2 Likes

It works but i am noticing if the speed is over 100 it get a little farther off. So how do i add:

If Speed is over 100 then = Speed - 40

nm. I followed your lead. Got it! Thanks

1 Like