Local variables are helpful when an expression needs to be used in the same formula several times. For example:

IF time_spent + remaining_estimate > 0 :
   time_spent / (time_spent + remaining_estimate)
CODE

You can see that in this formula we are using "time_spent + remaining_estimate" twice – once when we check that it's not zero (so we don't divide by zero) and again when we divide by it.

Instead of repeating the expression every time, we can rewrite this formula using the WITH construct:

WITH total_time = time_spent + remaining_estimate :
  IF total_time > 0 :
     time_spent / total_time
CODE

You can define multiple local variables in succession. You can also use previously defined local variables when defining additional local variables. For example:

WITH total_time = time_spent + remaining_estimate :
WITH progress = (IF total_time > 0 : time_spent / total_time) :
  IF(progress > 0.5, "Great Progress!", progress > 0.2, "Good Progress", "Needs Progress!")
CODE


Note the position of the colon (":") – it must be present where each local variable definition ends.